
<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   
      <title>Chapter&nbsp;6.&nbsp;Names</title>
      <link rel="stylesheet" type="text/css" href="../../../javaspec.css">
      <meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1">
      <link rel="home" href="index.html" title="The Java&reg; Language Specification">
      <link rel="up" href="index.html" title="The Java&reg; Language Specification">
      <link rel="prev" href="jls-5.html" title="Chapter&nbsp;5.&nbsp;Conversions and Contexts">
      <link rel="next" href="jls-7.html" title="Chapter&nbsp;7.&nbsp;Packages">
      <link rel="copyright" href="jls-0-front.html" title="Legal Notice">
   </head>
   <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
      <div xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:rx="http://www.renderx.com/XSL/Extensions" id="logo"><img src="http://www.oracleimg.com/us/assets/oralogo-small.gif" alt="Oracle Logo"><br><p><a target="_blank" href="http://www.oracle.com/us/technologies/java/">Oracle
               Technology Network</a> &gt; <a target="_blank" href="http://docs.oracle.com/javase/">Java SE</a>
                &gt; <a href="index.html">Java Language Specification</a></p>
      </div>
      <div class="navheader">
         <table width="100%" summary="Navigation header">
            <tr>
               <th colspan="3" align="center">Chapter&nbsp;6.&nbsp;Names</th>
            </tr>
            <tr>
               <td width="20%" align="left"><a accesskey="p" href="jls-5.html">Prev</a>&nbsp;
               </td>
               <th width="60%" align="center">&nbsp;</th>
               <td width="20%" align="right">&nbsp;<a accesskey="n" href="jls-7.html">Next</a></td>
            </tr>
         </table>
         <hr>
      </div>
      <div lang="en" class="chapter" title="Chapter&nbsp;6.&nbsp;Names">
         <div class="titlepage">
            <div>
               <div>
                  <h2 class="title"><a name="jls-6"></a>Chapter&nbsp;6.&nbsp;Names
                  </h2>
               </div>
            </div>
         </div>
         <div class="toc">
            <p><b>Table of Contents</b></p>
            <dl>
               <dt><span class="section"><a href="jls-6.html#jls-6.1">6.1. Declarations</a></span></dt>
               <dt><span class="section"><a href="jls-6.html#jls-6.2">6.2. Names and Identifiers</a></span></dt>
               <dt><span class="section"><a href="jls-6.html#jls-6.3">6.3. Scope of a Declaration</a></span></dt>
               <dt><span class="section"><a href="jls-6.html#jls-6.4">6.4. Shadowing and Obscuring</a></span></dt>
               <dd>
                  <dl>
                     <dt><span class="section"><a href="jls-6.html#jls-6.4.1">6.4.1. Shadowing</a></span></dt>
                     <dt><span class="section"><a href="jls-6.html#jls-6.4.2">6.4.2. Obscuring</a></span></dt>
                  </dl>
               </dd>
               <dt><span class="section"><a href="jls-6.html#jls-6.5">6.5. Determining the Meaning of a Name</a></span></dt>
               <dd>
                  <dl>
                     <dt><span class="section"><a href="jls-6.html#jls-6.5.1">6.5.1. Syntactic Classification of a Name According to Context</a></span></dt>
                     <dt><span class="section"><a href="jls-6.html#jls-6.5.2">6.5.2. Reclassification of Contextually Ambiguous Names</a></span></dt>
                     <dt><span class="section"><a href="jls-6.html#jls-6.5.3">6.5.3. Meaning of Package Names</a></span></dt>
                     <dd>
                        <dl>
                           <dt><span class="section"><a href="jls-6.html#jls-6.5.3.1">6.5.3.1. Simple Package Names</a></span></dt>
                           <dt><span class="section"><a href="jls-6.html#jls-6.5.3.2">6.5.3.2. Qualified Package Names</a></span></dt>
                        </dl>
                     </dd>
                     <dt><span class="section"><a href="jls-6.html#jls-6.5.4">6.5.4. Meaning of <span class="emphasis"><em>PackageOrTypeNames</em></span></a></span></dt>
                     <dd>
                        <dl>
                           <dt><span class="section"><a href="jls-6.html#jls-6.5.4.1">6.5.4.1. Simple <span class="emphasis"><em>PackageOrTypeNames</em></span></a></span></dt>
                           <dt><span class="section"><a href="jls-6.html#jls-6.5.4.2">6.5.4.2. Qualified <span class="emphasis"><em>PackageOrTypeNames</em></span></a></span></dt>
                        </dl>
                     </dd>
                     <dt><span class="section"><a href="jls-6.html#jls-6.5.5">6.5.5. Meaning of Type Names</a></span></dt>
                     <dd>
                        <dl>
                           <dt><span class="section"><a href="jls-6.html#jls-6.5.5.1">6.5.5.1. Simple Type Names</a></span></dt>
                           <dt><span class="section"><a href="jls-6.html#jls-6.5.5.2">6.5.5.2. Qualified Type Names</a></span></dt>
                        </dl>
                     </dd>
                     <dt><span class="section"><a href="jls-6.html#jls-6.5.6">6.5.6. Meaning of Expression Names</a></span></dt>
                     <dd>
                        <dl>
                           <dt><span class="section"><a href="jls-6.html#jls-6.5.6.1">6.5.6.1. Simple Expression Names</a></span></dt>
                           <dt><span class="section"><a href="jls-6.html#jls-6.5.6.2">6.5.6.2. Qualified Expression Names</a></span></dt>
                        </dl>
                     </dd>
                     <dt><span class="section"><a href="jls-6.html#jls-6.5.7">6.5.7. Meaning of Method Names</a></span></dt>
                     <dd>
                        <dl>
                           <dt><span class="section"><a href="jls-6.html#jls-6.5.7.1">6.5.7.1. Simple Method Names</a></span></dt>
                        </dl>
                     </dd>
                  </dl>
               </dd>
               <dt><span class="section"><a href="jls-6.html#jls-6.6">6.6. Access Control</a></span></dt>
               <dd>
                  <dl>
                     <dt><span class="section"><a href="jls-6.html#jls-6.6.1">6.6.1. Determining Accessibility</a></span></dt>
                     <dt><span class="section"><a href="jls-6.html#jls-6.6.2">6.6.2. Details on protected Access</a></span></dt>
                     <dd>
                        <dl>
                           <dt><span class="section"><a href="jls-6.html#jls-6.6.2.1">6.6.2.1. Access to a <code class="literal">protected</code> Member</a></span></dt>
                           <dt><span class="section"><a href="jls-6.html#jls-6.6.2.2">6.6.2.2. Qualified Access to a <code class="literal">protected</code> Constructor</a></span></dt>
                        </dl>
                     </dd>
                  </dl>
               </dd>
               <dt><span class="section"><a href="jls-6.html#jls-6.7">6.7. Fully Qualified Names and Canonical Names</a></span></dt>
            </dl>
         </div>
         <p class="norm"><a name="jls-6-100"></a>Names are used to refer to
            entities declared in a program.
         </p>
         <p class="norm"><a name="jls-6-110"></a>A declared entity
            (<a class="xref" href="jls-6.html#jls-6.1" title="6.1.&nbsp;Declarations">&sect;6.1</a>) is a package, class type (normal or enum),
            interface type (normal or annotation type), member (class, interface,
            field, or method) of a reference type, type parameter (of a class,
            interface, method or constructor), parameter (to a method,
            constructor, or exception handler), or local variable.
         </p>
         <p class="norm"><a name="jls-6-120"></a>Names in programs are
            either <span class="emphasis"><em>simple</em></span>, consisting of a single identifier,
            or <span class="emphasis"><em>qualified</em></span>, consisting of a sequence of
            identifiers separated by "<code class="literal">.</code>" tokens (<a class="xref" href="jls-6.html#jls-6.2" title="6.2.&nbsp;Names and Identifiers">&sect;6.2</a>).
         </p>
         <p class="norm"><a name="jls-6-130"></a>Every declaration that introduces
            a name has a <span class="emphasis"><em>scope</em></span> (<a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a>),
            which is the part of the program text within which the declared entity
            can be referred to by a simple name.
         </p>
         <p class="norm"><a name="jls-6-140"></a>A qualified
            name <code class="varname">N.x</code> may be used to refer to
            a <span class="emphasis"><em>member</em></span> of a package or reference
            type, where <code class="varname">N</code> is a simple
            or qualified name and <code class="varname">x</code> is an
            identifier. If <code class="varname">N</code> names a package,
            then <code class="varname">x</code> is a member of that package, which is either
            a class or interface type or a subpackage. If <code class="varname">N</code>
            names a reference type or a variable of a reference type,
            then <code class="varname">x</code> names a member of that type, which is either
            a class, an interface, a field, or a method.
         </p>
         <p class="norm"><a name="jls-6-150"></a>In determining the meaning of a
            name (<a class="xref" href="jls-6.html#jls-6.5" title="6.5.&nbsp;Determining the Meaning of a Name">&sect;6.5</a>), the context of the occurrence is
            used to disambiguate among packages, types, variables, and methods
            with the same name.
         </p>
         <p class="norm"><a name="jls-6-160"></a>Access control
            (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>) can be specified in a class, interface,
            method, or field declaration to control
            when <span class="emphasis"><em>access</em></span> to a member is allowed. Access is a
            different concept from scope. Access specifies the part of the program
            text within which the declared entity can be referred to by a
            qualified name. Access to a declared entity is also relevant in a
            field access expression (<a class="xref" href="jls-15.html#jls-15.11" title="15.11.&nbsp;Field Access Expressions">&sect;15.11</a>), a method
            invocation expression in which the method is not specified by a simple
            name (<a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>), a method reference expression
            (<a class="xref" href="jls-15.html#jls-15.13" title="15.13.&nbsp;Method Reference Expressions">&sect;15.13</a>), or a qualified class instance creation
            expression (<a class="xref" href="jls-15.html#jls-15.9" title="15.9.&nbsp;Class Instance Creation Expressions">&sect;15.9</a>). In the absence of an access
            modifier, most declarations have package access, allowing access
            anywhere within the package that contains its declaration; other
            possibilities are <code class="literal">public</code>, <code class="literal">protected</code>, and <code class="literal">private</code>.
         </p>
         <p class="norm"><a name="jls-6-170"></a>Fully qualified and canonical
            names (<a class="xref" href="jls-6.html#jls-6.7" title="6.7.&nbsp;Fully Qualified Names and Canonical Names">&sect;6.7</a>) are also discussed in this
            chapter.
         </p>
         <div class="section" title="6.1.&nbsp;Declarations">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-6.1"></a>6.1.&nbsp;Declarations
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-6.1-100"></a>A 
               <span class="emphasis"><em>declaration</em></span> introduces an entity into a program
               and includes an identifier (<a class="xref" href="jls-3.html#jls-3.8" title="3.8.&nbsp;Identifiers">&sect;3.8</a>) that can be
               used in a name to refer to this entity.
            </p>
            <p class="norm-static"><a name="jls-6.1-110"></a>A declared
               entity is one of the following:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.1-110-A"></a>
                              A package, declared in a <code class="literal">package</code> declaration
                              (<a class="xref" href="jls-7.html#jls-7.4" title="7.4.&nbsp;Package Declarations">&sect;7.4</a>)
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.1-110-B"></a>
                              An imported type, declared in a single-type-import declaration
                              or a type-import-on-demand declaration
                              (<a class="xref" href="jls-7.html#jls-7.5.1" title="7.5.1.&nbsp;Single-Type-Import Declarations">&sect;7.5.1</a>,
                              <a class="xref" href="jls-7.html#jls-7.5.2" title="7.5.2.&nbsp;Type-Import-on-Demand Declarations">&sect;7.5.2</a>)
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.1-110-C"></a>
                              An imported <code class="literal">static</code> member, declared in a single-static-import
                              declaration or a static-import-on-demand declaration
                              (<a class="xref" href="jls-7.html#jls-7.5.3" title="7.5.3.&nbsp;Single-Static-Import Declarations">&sect;7.5.3</a>,
                              <a class="xref" href="jls-7.html#jls-7.5.4" title="7.5.4.&nbsp;Static-Import-on-Demand Declarations">&sect;7.5.4</a>)
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.1-110-D"></a>
                              A class, declared in a class type declaration
                              (<a class="xref" href="jls-8.html#jls-8.1" title="8.1.&nbsp;Class Declarations">&sect;8.1</a>)
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.1-110-E"></a>
                              An interface, declared in an interface type declaration
                              (<a class="xref" href="jls-9.html#jls-9.1" title="9.1.&nbsp;Interface Declarations">&sect;9.1</a>)
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.1-110-F"></a>
                              A type parameter, declared as part of the declaration of a
                              generic class, interface, method, or constructor
                              (<a class="xref" href="jls-8.html#jls-8.1.2" title="8.1.2.&nbsp;Generic Classes and Type Parameters">&sect;8.1.2</a>, <a class="xref" href="jls-9.html#jls-9.1.2" title="9.1.2.&nbsp;Generic Interfaces and Type Parameters">&sect;9.1.2</a>,
                              <a class="xref" href="jls-8.html#jls-8.4.4" title="8.4.4.&nbsp;Generic Methods">&sect;8.4.4</a>, <a class="xref" href="jls-8.html#jls-8.8.4" title="8.8.4.&nbsp;Generic Constructors">&sect;8.8.4</a>)
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.1-110-G"></a>
                              A member of a reference type (<a class="xref" href="jls-8.html#jls-8.2" title="8.2.&nbsp;Class Members">&sect;8.2</a>,
                              <a class="xref" href="jls-9.html#jls-9.2" title="9.2.&nbsp;Interface Members">&sect;9.2</a>, <a class="xref" href="jls-8.html#jls-8.9.3" title="8.9.3.&nbsp;Enum Members">&sect;8.9.3</a>,
                              <a class="xref" href="jls-9.html#jls-9.6" title="9.6.&nbsp;Annotation Types">&sect;9.6</a>, <a class="xref" href="jls-10.html#jls-10.7" title="10.7.&nbsp;Array Members">&sect;10.7</a>), one of
                              the following:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-G-A"></a>
                                 	  A member class (<a class="xref" href="jls-8.html#jls-8.5" title="8.5.&nbsp;Member Type Declarations">&sect;8.5</a>,
                                           <a class="xref" href="jls-9.html#jls-9.5" title="9.5.&nbsp;Member Type Declarations">&sect;9.5</a>)
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-G-B"></a>
                                 	  A member interface (<a class="xref" href="jls-8.html#jls-8.5" title="8.5.&nbsp;Member Type Declarations">&sect;8.5</a>,
                                           <a class="xref" href="jls-9.html#jls-9.5" title="9.5.&nbsp;Member Type Declarations">&sect;9.5</a>)
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-G-C"></a>
                                 	  An enum constant (<a class="xref" href="jls-8.html#jls-8.9" title="8.9.&nbsp;Enum Types">&sect;8.9</a>)
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-G-D"></a>
                                 	  A field, one of the following:
                              </p>
                              <div class="norm">
                                 <ul class="norm" type="square">
                                    <li class="listitem">
                                       <p class="norm-static"><a name="jls-6.1-110-G-D-A"></a>
                                          	      A field declared in a class type or enum type
                                                        (<a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a>,
                                                        <a class="xref" href="jls-8.html#jls-8.9.2" title="8.9.2.&nbsp;Enum Body Declarations">&sect;8.9.2</a>)
                                       </p>
                                    </li>
                                    <li class="listitem">
                                       <p class="norm-static"><a name="jls-6.1-110-G-D-B"></a>
                                          	      A field declared in an interface type or annotation type
                                                        (<a class="xref" href="jls-9.html#jls-9.3" title="9.3.&nbsp;Field (Constant) Declarations">&sect;9.3</a>,
                                                        <a class="xref" href="jls-9.html#jls-9.6.1" title="9.6.1.&nbsp;Annotation Type Elements">&sect;9.6.1</a>)
                                       </p>
                                    </li>
                                    <li class="listitem">
                                       <p class="norm-static"><a name="jls-6.1-110-G-D-C"></a>
                                          	      The field <code class="literal">length</code>, which is implicitly a member of
                                                        every array type (<a class="xref" href="jls-10.html#jls-10.7" title="10.7.&nbsp;Array Members">&sect;10.7</a>)
                                       </p>
                                    </li>
                                 </ul>
                              </div>
                           </li>
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-G-E"></a>
                                 	  A method, one of the following:
                              </p>
                              <div class="norm">
                                 <ul class="norm" type="square">
                                    <li class="listitem">
                                       <p class="norm-static"><a name="jls-6.1-110-G-E-A"></a>
                                          	      A method (<code class="literal">abstract</code> or otherwise) declared in a class
                                                        type or enum type (<a class="xref" href="jls-8.html#jls-8.4" title="8.4.&nbsp;Method Declarations">&sect;8.4</a>,
                                                        <a class="xref" href="jls-8.html#jls-8.9.2" title="8.9.2.&nbsp;Enum Body Declarations">&sect;8.9.2</a>)
                                       </p>
                                    </li>
                                    <li class="listitem">
                                       <p class="norm-static"><a name="jls-6.1-110-G-E-B"></a>
                                          	      A method (always <code class="literal">abstract</code>) declared in an interface
                                                        type or annotation type (<a class="xref" href="jls-9.html#jls-9.4" title="9.4.&nbsp;Method Declarations">&sect;9.4</a>,
                                                        <a class="xref" href="jls-9.html#jls-9.6.1" title="9.6.1.&nbsp;Annotation Type Elements">&sect;9.6.1</a>)
                                       </p>
                                    </li>
                                 </ul>
                              </div>
                           </li>
                        </ul>
                     </div>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.1-110-H"></a>
                              A parameter, one of the following:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-H-A"></a>
                                 	  A formal parameter of a method or constructor of a class
                                           type or enum type (<a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a>,
                                           <a class="xref" href="jls-8.html#jls-8.8.1" title="8.8.1.&nbsp;Formal Parameters">&sect;8.8.1</a>, <a class="xref" href="jls-8.html#jls-8.9.2" title="8.9.2.&nbsp;Enum Body Declarations">&sect;8.9.2</a>),
                                           or of a lambda expression
                                           (<a class="xref" href="jls-15.html#jls-15.27.1" title="15.27.1.&nbsp;Lambda Parameters">&sect;15.27.1</a>)
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-H-B"></a>
                                 	  A formal parameter of an <code class="literal">abstract</code> method of an interface
                                           type or annotation type (<a class="xref" href="jls-9.html#jls-9.4" title="9.4.&nbsp;Method Declarations">&sect;9.4</a>,
                                           <a class="xref" href="jls-9.html#jls-9.6.1" title="9.6.1.&nbsp;Annotation Type Elements">&sect;9.6.1</a>)
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-H-C"></a>
                                 	  An exception parameter of an exception handler declared in a
                                           <code class="literal">catch</code> clause of a <code class="literal">try</code> statement
                                           (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>)
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.1-110-I"></a>
                              A local variable, one of the following:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-I-A"></a>
                                 	  A local variable declared in a block
                                           (<a class="xref" href="jls-14.html#jls-14.4" title="14.4.&nbsp;Local Variable Declaration Statements">&sect;14.4</a>)
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm-static"><a name="jls-6.1-110-I-B"></a>
                                 	  A local variable declared in a <code class="literal">for</code> statement
                                           (<a class="xref" href="jls-14.html#jls-14.14" title="14.14.&nbsp;The for Statement">&sect;14.14</a>)
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
               </ul>
            </div>
            <p class="norm-static"><a name="jls-6.1-120"></a>Constructors
               (<a class="xref" href="jls-8.html#jls-8.8" title="8.8.&nbsp;Constructor Declarations">&sect;8.8</a>) are also introduced by declarations, but
               use the name of the class in which they are declared rather than
               introducing a new name.
            </p>
            <p class="norm"><a name="jls-6.1-200"></a>The declaration of a type which is not
               generic (<code class="literal">class C ...</code>) declares one entity: a
               non-generic type (<code class="literal">C</code>). A non-generic type is not a
               raw type, despite the syntactic similarity. In contrast, the
               declaration of a generic type (<code class="literal">class C&lt;T&gt; ...</code>
               or <code class="literal">interface C&lt;T&gt; ...</code>) declares two entities:
               a generic type (<code class="literal">C&lt;T&gt;</code>) and a corresponding
               non-generic type (<code class="literal">C</code>). In this case, the meaning of
               the term <code class="literal">C</code> depends on the context where it
               appears:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-200-A"></a>
                              If genericity is unimportant, as in the <span class="emphasis"><em>non-generic
                                    contexts</em></span> identified below, the
                              identifier <code class="literal">C</code> denotes the non-generic
                              type <code class="literal">C</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-200-B"></a>
                              If genericity is important, as in all contexts from
                              <a class="xref" href="jls-6.html#jls-6.5" title="6.5.&nbsp;Determining the Meaning of a Name">&sect;6.5</a> except the non-generic contexts, the
                              identifier <code class="literal">C</code> denotes either:
                     </p>
                     <div class="norm">
                        <ul class="norm" type="circle">
                           <li class="listitem">
                              <p class="norm"><a name="jls-6.1-200-B-A"></a>
                                 	  The raw type <code class="literal">C</code> which is the erasure
                                 	  (<a class="xref" href="jls-4.html#jls-4.6" title="4.6.&nbsp;Type Erasure">&sect;4.6</a>) of the generic
                                 	  type <code class="literal">C&lt;T&gt;</code>; or
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="norm"><a name="jls-6.1-200-B-B"></a>
                                 	  A parameterized type which is a particular parameterization
                                 	  (<a class="xref" href="jls-4.html#jls-4.5" title="4.5.&nbsp;Parameterized Types">&sect;4.5</a>) of the generic
                                 	  type <code class="literal">C&lt;T&gt;</code>.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </li>
               </ul>
            </div>
            <p class="norm"><a name="jls-6.1-210"></a>The 13 non-generic contexts are as
               follows:
            </p>
            <div class="orderedlist">
               <ol class="orderedlist" type="1">
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-A"></a>
                              In a single-type-import declaration
                              (<a class="xref" href="jls-7.html#jls-7.5.1" title="7.5.1.&nbsp;Single-Type-Import Declarations">&sect;7.5.1</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-B"></a>
                              To the left of the <code class="literal">.</code> in a single-static-import declaration
                              (<a class="xref" href="jls-7.html#jls-7.5.3" title="7.5.3.&nbsp;Single-Static-Import Declarations">&sect;7.5.3</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-C"></a>
                              To the left of the <code class="literal">.</code> in a static-import-on-demand
                              declaration (<a class="xref" href="jls-7.html#jls-7.5.4" title="7.5.4.&nbsp;Static-Import-on-Demand Declarations">&sect;7.5.4</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-D"></a>
                              To the left of the <code class="literal">(</code> in a constructor declaration
                              (<a class="xref" href="jls-8.html#jls-8.8" title="8.8.&nbsp;Constructor Declarations">&sect;8.8</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-E"></a>
                              After the <code class="literal">@</code> sign in an annotation (<a class="xref" href="jls-9.html#jls-9.7" title="9.7.&nbsp;Annotations">&sect;9.7</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-F"></a>
                              To the left of <code class="literal">.</code><code class="literal">class</code> in a class literal
                              (<a class="xref" href="jls-15.html#jls-15.8.2" title="15.8.2.&nbsp;Class Literals">&sect;15.8.2</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-G"></a>
                              To the left of <code class="literal">.</code><code class="literal">this</code> in a qualified <code class="literal">this</code> expression
                              (<a class="xref" href="jls-15.html#jls-15.8.4" title="15.8.4.&nbsp;Qualified this">&sect;15.8.4</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-H"></a>
                              To the left of <code class="literal">.</code><code class="literal">super</code> in a qualified superclass field
                              access expression (<a class="xref" href="jls-15.html#jls-15.11.2" title="15.11.2.&nbsp;Accessing Superclass Members using super">&sect;15.11.2</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-I"></a>
                              To the left of <code class="literal">.</code><span class="emphasis"><em>Identifier</em></span> or
                              <code class="literal">.</code><code class="literal">super</code><code class="literal">.</code><span class="emphasis"><em>Identifier</em></span> in a qualified method invocation
                              expression (<a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-J"></a>
                              To the left of <code class="literal">.</code><code class="literal">super</code><code class="literal">::</code> in a method reference
                              expression (<a class="xref" href="jls-15.html#jls-15.13" title="15.13.&nbsp;Method Reference Expressions">&sect;15.13</a>) 
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-K"></a>
                              In a qualified expression name in a postfix expression
                              (<a class="xref" href="jls-15.html#jls-15.14.1" title="15.14.1.&nbsp;Expression Names">&sect;15.14.1</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-L"></a>
                              In a <code class="literal">throws</code> clause of a method or constructor
                              (<a class="xref" href="jls-8.html#jls-8.4.6" title="8.4.6.&nbsp;Method Throws">&sect;8.4.6</a>, <a class="xref" href="jls-8.html#jls-8.8.5" title="8.8.5.&nbsp;Constructor Throws">&sect;8.8.5</a>,
                              <a class="xref" href="jls-9.html#jls-9.4" title="9.4.&nbsp;Method Declarations">&sect;9.4</a>)
                            
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.1-210-M"></a>
                              In an exception parameter declaration
                              (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>)
                            
                     </p>
                  </li>
               </ol>
            </div>
            <p class="norm"><a name="jls-6.1-220"></a>The first ten non-generic contexts
               correspond to the first ten syntactic contexts for a <span class="emphasis"><em>TypeName</em></span> in
               <a class="xref" href="jls-6.html#jls-6.5.1" title="6.5.1.&nbsp;Syntactic Classification of a Name According to Context">&sect;6.5.1</a>. The eleventh non-generic context is a
               postfix expression, where a qualified <span class="emphasis"><em>ExpressionName</em></span> such
               as <code class="literal">C.x</code> may include a
               <span class="emphasis"><em>TypeName</em></span> <code class="literal">C</code> to denote static member access. The
               common use of <span class="emphasis"><em>TypeName</em></span> is significant: it indicates that these
               contexts involve a less-than-first-class use of a type. In contrast,
               the twelfth and thirteenth non-generic contexts employ <span class="emphasis"><em>ClassType</em></span>,
               indicating that <code class="literal">throws</code> and <code class="literal">catch</code> clauses use types in a
               first-class way, in line with, say, field declarations. The
               characterization of these two contexts as non-generic is due to the
               fact that an exception type cannot be parameterized.
            </p>
            <p class="note">
               Note that the <span class="emphasis"><em>ClassType</em></span> production allows annotations, so it is
               possible to annotate the use of a type in a <code class="literal">throws</code> or <code class="literal">catch</code>
               clause, whereas the <span class="emphasis"><em>TypeName</em></span> production disallows annotations, so it
               is not possible to annotate the name of a type in, say, a
               single-type-import declaration.
            </p>
            <p class="note"><span class="emphasis"><em>Naming Conventions</em></span></p>
            <p class="note">The class libraries of the Java SE platform attempt to
               use, whenever possible, names chosen according to the conventions
               presented below. These conventions help to make code more readable and
               avoid certain kinds of name conflicts.
            </p>
            <p class="note">We recommend these conventions for use in all
               programs written in the Java programming language. However, these
               conventions should not be followed slavishly if long-held conventional
               usage dictates otherwise. So, for example, the <code class="literal">sin</code>
               and <code class="literal">cos</code> methods of the
               class <code class="literal">java.lang.Math</code> have mathematically
               conventional names, even though these method names flout the
               convention suggested here because they are short and are not
               verbs.
            </p>
            <p class="note"><span class="emphasis"><em>Package Names</em></span></p>
            <p class="note">Developers should take steps to avoid the
               possibility of two published packages having the same name by
               choosing <span class="emphasis"><em>unique package names</em></span> for packages that
               are widely distributed. This allows packages to be easily and
               automatically installed and catalogued. This section specifies a
               suggested convention for generating such unique package
               names. Implementations of the Java SE platform are encouraged to provide
               automatic support for converting a set of packages from local and
               casual package names to the unique name format described here.
            </p>
            <p class="note">If unique package names are not used, then package
               name conflicts may arise far from the point of creation of either of
               the conflicting packages. This may create a situation that is
               difficult or impossible for the user or programmer to resolve. The
               class <code class="literal">ClassLoader</code> can be used to isolate packages with the same name
               from each other in those cases where the packages will have
               constrained interactions, but not in a way that is transparent to a
               na&iuml;ve program.
            </p>
            <p class="note">You form a unique package name by first having (or
               belonging to an organization that has) an Internet domain name, such
               as <code class="literal">oracle.com</code>. You then reverse this name,
               component by component, to obtain, in this
               example, <code class="literal">com.oracle</code>, and use this as a prefix for
               your package names, using a convention developed within your
               organization to further administer package names. Such a convention
               might specify that certain  package name components be
               division, department, project, machine, or login names.
            </p>
            <div class="example"><a name="d5e8161"></a><p class="title"><b>Example&nbsp;6.1-1.&nbsp;Unique Package Names</b></p>
               <div class="example-contents"><pre class="screen">
com.nighthacks.java.jag.scrabble
org.openjdk.tools.compiler
net.jcip.annotations
edu.cmu.cs.bovik.cheese
gov.whitehouse.socks.mousefinder
</pre></div>
            </div><br class="example-break"><p class="note">The first component of a unique package name is
               always written in all-lowercase ASCII letters and should be one of the
               top level domain names, such as <code class="literal">com</code>, 
               <code class="literal">edu</code>, <code class="literal">gov</code>, <code class="literal">mil</code>, 
               <code class="literal">net</code>, or <code class="literal">org</code>, or one of the
               English two-letter codes identifying countries as specified
               in <em class="citetitle">ISO Standard 3166</em>.
            </p>
            <p class="note">The name of a package is not meant to imply where
               the package is stored on the Internet. The suggested convention for
               generating unique package names is merely a way to piggyback a package
               naming convention on top of an existing, widely known unique name
               registry instead of having to create a separate registry for package
               names.
            </p>
            <div class="informalexample">
               <p class="note">For example, a package
                  named <code class="literal">edu.cmu.cs.bovik.cheese</code> is not necessarily
                  obtainable from Internet address <code class="literal">cmu.edu</code>
                  or <code class="literal">cs.cmu.edu</code>
                  or <code class="literal">bovik.cs.cmu.edu</code>.
               </p>
            </div>
            <p class="note">In some cases, the Internet domain name may not be a
               valid package name. Here are some suggested conventions for dealing
               with these situations:
            </p>
            <div class="note">
               <ul class="note" type="disc">
                  <li class="listitem">
                     <p class="note">If the domain name contains a hyphen, or any
                              other special character not allowed in an identifier
                              (<a class="xref" href="jls-3.html#jls-3.8" title="3.8.&nbsp;Identifiers">&sect;3.8</a>), convert it into an
                              underscore.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="note">If any of the resulting package name components
                              are keywords (<a class="xref" href="jls-3.html#jls-3.9" title="3.9.&nbsp;Keywords">&sect;3.9</a>), append an underscore
                              to them.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="note">If any of the resulting package name components
                              start with a digit, or any other character that is not allowed
                              as an initial character of an identifier, have an underscore
                              prefixed to the component.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="note">Names of packages intended only for local use should
               have a first identifier that begins with a lowercase letter, but that
               first identifier specifically should not be the
               identifier <code class="literal">java</code>; package names that start with the
               identifier <code class="literal">java</code> are reserved for package of the
               Java SE platform.
            </p>
            <p class="note"><span class="emphasis"><em>Class and Interface Type
                     Names</em></span></p>
            <p class="note">Names of class types should be descriptive nouns or
               noun phrases, not overly long, in mixed case with the first letter of
               each word capitalized.
            </p>
            <div class="example"><a name="d5e8195"></a><p class="title"><b>Example&nbsp;6.1-2.&nbsp;Descriptive Class Names</b></p>
               <div class="example-contents"><pre class="screen">
<code class="literal">ClassLoader</code>
SecurityManager
<code class="literal">Thread</code>
Dictionary
BufferedInputStream
</pre></div>
            </div><br class="example-break"><p class="note">Likewise, names of interface types should be short
               and descriptive, not overly long, in mixed case with the first letter
               of each word capitalized. The name may be a descriptive noun or noun
               phrase, which is appropriate when an interface is used as if it were
               an abstract superclass, such as interfaces
               <code class="literal">java.io.DataInput</code> and 
               <code class="literal">java.io.DataOutput</code>; or it may be an adjective
               describing a behavior, as for the interfaces 
               <code class="literal">Runnable</code> and <code class="literal">Cloneable</code>.
            </p>
            <p class="note"><span class="emphasis"><em>Type Variable Names</em></span></p>
            <p class="note">Type variable names should be pithy (single
               character if possible) yet evocative, and should not include lower
               case letters. This makes it easy to distinguish type parameters from
               ordinary classes and interfaces.
            </p>
            <p class="note">Container types should use the
               name <code class="literal">E</code> for their element type. Maps should
               use <code class="literal">K</code> for the type of their keys
               and <code class="literal">V</code> for the type of their values. The
               name <code class="literal">X</code> should be used for arbitrary exception
               types. We use <code class="literal">T</code> for type, whenever there is not
               anything more specific about the type to distinguish it. (This is
               often the case in generic methods.)
            </p>
            <p class="note">If there are multiple type parameters that denote
               arbitrary types, one should use letters that
               neighbor <code class="literal">T</code> in the alphabet, such
               as <code class="literal">S</code>. Alternately, it is acceptable to use numeric
               subscripts (e.g., <code class="literal">T1</code>, <code class="literal">T2</code>) to
               distinguish among the different type variables. In such cases, all the
               variables with the same prefix should be subscripted.
            </p>
            <p class="note">If a generic method appears inside a generic class,
               it is a good idea to avoid using the same names for the type
               parameters of the method and class, to avoid confusion. The same
               applies to nested generic classes.
            </p>
            <div class="example"><a name="d5e8220"></a><p class="title"><b>Example&nbsp;6.1-3.&nbsp;Conventional Type Variable Names</b></p>
               <div class="example-contents"><pre class="programlisting">

public class HashSet&lt;E&gt; extends AbstractSet&lt;E&gt; { ... }
public class HashMap&lt;K,V&gt; extends AbstractMap&lt;K,V&gt; { ... }
public class ThreadLocal&lt;T&gt; { ... }
public interface Functor&lt;T, X extends Throwable&gt; {
    T eval() throws X;
}

</pre></div>
            </div><br class="example-break"><p class="note">When type parameters do not fall conveniently into
               one of the categories mentioned, names should be chosen to be as
               meaningful as possible within the confines of a single letter. The
               names mentioned above (<code class="literal">E</code>, <code class="literal">K</code>,
               <code class="literal">V</code>, <code class="literal">X</code>, <code class="literal">T</code>)
               should not be used for type parameters that do not fall into the
               designated categories.
            </p>
            <p class="note"><span class="emphasis"><em>Method Names</em></span></p>
            <p class="note">Method names should be verbs or verb phrases, in
               mixed case, with the first letter lowercase and the first letter of
               any subsequent words capitalized. Here are some additional specific
               conventions for method names:
            </p>
            <div class="note">
               <ul class="note" type="disc">
                  <li class="listitem">
                     <p class="note">Methods to get and set an attribute that might
                              be thought of as a variable <span class="emphasis"><em>V</em></span> should be
                              named <code class="literal">get<span class="emphasis"><em>V</em></span></code>
                              and <code class="literal">set<span class="emphasis"><em>V</em></span></code>. An example is
                              the methods <code class="literal">getPriority</code>
                              and <code class="literal">setPriority</code> of class <code class="literal">Thread</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="note">A method that returns the length of something
                              should be named <code class="literal">length</code>, as in class
                              <code class="literal">String</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="note">A method that tests a boolean
                              condition <span class="emphasis"><em>V</em></span> about an object should be
                              named <code class="literal">is<span class="emphasis"><em>V</em></span></code>. An example is
                              the method <code class="literal">isInterrupted</code> of class
                              <code class="literal">Thread</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="note">A method that converts its object to a
                              particular format <span class="emphasis"><em>F</em></span> should be
                              named <code class="literal">to<span class="emphasis"><em>F</em></span></code>. Examples are
                              the method <code class="literal">toString</code> of class <code class="literal">Object</code> and the
                              methods <code class="literal">toLocaleString</code>
                              and <code class="literal">toGMTString</code> of
                              class <code class="literal">java.util.Date</code>.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="note">Whenever possible and appropriate, basing the names
               of methods in a new class on names in an existing class that is
               similar, especially a class from the Java SE platform API, will make it
               easier to use.
            </p>
            <p class="note"><span class="emphasis"><em>Field Names</em></span></p>
            <p class="note">Names of fields that are not <code class="literal">final</code> should be in
               mixed case with a lowercase first letter and the first letters of
               subsequent words capitalized. Note that well-designed classes have
               very few <code class="literal">public</code> or <code class="literal">protected</code> fields, except for fields that are
               constants (<code class="literal">static</code> <code class="literal">final</code> fields).
            </p>
            <p class="note">Fields should have names that are nouns, noun
               phrases, or abbreviations for nouns.
            </p>
            <div class="informalexample">
               <p class="note">Examples of this convention are the
                  fields <code class="literal">buf</code>, <code class="literal">pos</code>,
                  and <code class="literal">count</code> of the
                  class <code class="literal">java.io.ByteArrayInputStream</code> and the
                  field <code class="literal">bytesTransferred</code> of the
                  class <code class="literal">java.io.InterruptedIOException</code>.
               </p>
            </div>
            <p class="note"><span class="emphasis"><em>Constant Names</em></span></p>
            <p class="note">The names of constants in interface types should be,
               and <code class="literal">final</code> variables of class types may conventionally be, a sequence
               of one or more words, acronyms, or abbreviations, all uppercase, with
               components separated by underscore "<code class="literal">_</code>"
               characters. Constant names should be descriptive and not unnecessarily
               abbreviated. Conventionally they may be any appropriate part of
               speech.
            </p>
            <div class="informalexample">
               <p class="note">Examples of names for constants
                  include <code class="literal">MIN_VALUE</code>, <code class="literal">MAX_VALUE</code>, 
                  <code class="literal">MIN_RADIX</code>, and <code class="literal">MAX_RADIX</code> of the
                  class <code class="literal">Character</code>.
               </p>
            </div>
            <p class="note">A group of constants that represent alternative
               values of a set, or, less frequently, masking bits in an integer
               value, are sometimes usefully specified with a common acronym as a
               name prefix.
            </p>
            <div class="informalexample">
               <p class="note">For example:</p><pre class="programlisting">
interface ProcessStates {
    int PS_RUNNING   = 0;
    int PS_SUSPENDED = 1;
}
</pre></div>
            <p class="note"><span class="emphasis"><em>Local Variable and Parameter
                     Names</em></span></p>
            <p class="note">Local variable and parameter names should be short,
               yet meaningful. They are often short sequences of lowercase letters
               that are not words, such as:
            </p>
            <div class="note">
               <ul class="note" type="disc">
                  <li class="listitem">
                     <p class="note">Acronyms, that is the first letter of a series
                              of words, as in <code class="literal">cp</code> for a variable holding a
                              reference to a <code class="literal">ColoredPoint</code></p>
                  </li>
                  <li class="listitem">
                     <p class="note">Abbreviations, as in <code class="literal">buf</code>
                              holding a pointer to a buffer of some kind
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="note">Mnemonic terms, organized in some way to aid
                              memory and understanding, typically by using a set of local
                              variables with conventional names patterned after the names of
                              parameters to widely used classes. For example:
                     </p>
                     <div class="note">
                        <ul class="note" type="circle">
                           <li class="listitem">
                              <p class="note"><code class="literal">in</code>
                                 	  and <code class="literal">out</code>, whenever some kind of input and
                                 	  output are involved, patterned after the fields
                                 	  of <code class="literal">System</code></p>
                           </li>
                           <li class="listitem">
                              <p class="note"><code class="literal">off</code>
                                 	  and <code class="literal">len</code>, whenever an offset and length
                                 	  are involved, patterned after the parameters to
                                 	  the <code class="literal">read</code> and <code class="literal">write</code>
                                 	  methods of the interfaces <code class="literal">DataInput</code>
                                 	  and <code class="literal">DataOutput</code>
                                 	  of <code class="literal">java.io</code></p>
                           </li>
                        </ul>
                     </div>
                  </li>
               </ul>
            </div>
            <p class="note">One-character local variable or parameter names
               should be avoided, except for temporary and looping variables, or
               where a variable holds an undistinguished value of a
               type. Conventional one-character names are:
            </p>
            <div class="note">
               <ul class="note" type="disc">
                  <li class="listitem">
                     <p class="note"><code class="literal">b</code> for a <code class="literal">byte</code></p>
                  </li>
                  <li class="listitem">
                     <p class="note"><code class="literal">c</code> for a <code class="literal">char</code></p>
                  </li>
                  <li class="listitem">
                     <p class="note"><code class="literal">d</code> for a <code class="literal">double</code></p>
                  </li>
                  <li class="listitem">
                     <p class="note"><code class="literal">e</code> for an <code class="literal">Exception</code></p>
                  </li>
                  <li class="listitem">
                     <p class="note"><code class="literal">f</code> for a <code class="literal">float</code></p>
                  </li>
                  <li class="listitem">
                     <p class="note"><code class="literal">i</code>, <code class="literal">j</code>,
                            and <code class="literal">k</code> for <code class="literal">int</code>s
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="note"><code class="literal">l</code> for a <code class="literal">long</code></p>
                  </li>
                  <li class="listitem">
                     <p class="note"><code class="literal">o</code> for an <code class="literal">Object</code></p>
                  </li>
                  <li class="listitem">
                     <p class="note"><code class="literal">s</code> for a <code class="literal">String</code></p>
                  </li>
                  <li class="listitem">
                     <p class="note"><code class="literal">v</code> for an arbitrary value of
                            some type
                     </p>
                  </li>
               </ul>
            </div>
            <p class="note">Local variable or parameter names that consist of
               only two or three lowercase letters should not conflict with the
               initial country codes and domain names that are the first component of
               unique package names.
            </p>
         </div>
         <div class="section" title="6.2.&nbsp;Names and Identifiers">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-6.2"></a>6.2.&nbsp;Names and Identifiers
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-6.2-100"></a>A <span class="emphasis"><em>name</em></span> is
               used to refer to an entity declared in a program.
            </p>
            <p class="norm"><a name="jls-6.2-110"></a>There are two forms of names:
               simple names and qualified names.
            </p>
            <p class="norm"><a name="jls-6.2-120"></a>A <span class="emphasis"><em>simple
                     name</em></span> is a single identifier.
            </p>
            <p class="norm"><a name="jls-6.2-130"></a>A <span class="emphasis"><em>qualified
                     name</em></span> consists of a name, a "<code class="literal">.</code>" token, and an
               identifier.
            </p>
            <p class="norm"><a name="jls-6.2-200"></a>In determining the meaning of a
               name (<a class="xref" href="jls-6.html#jls-6.5" title="6.5.&nbsp;Determining the Meaning of a Name">&sect;6.5</a>), the context in which the name
               appears is taken into account. The rules of <a class="xref" href="jls-6.html#jls-6.5" title="6.5.&nbsp;Determining the Meaning of a Name">&sect;6.5</a>
               distinguish among contexts where a name must denote (refer to) a
               package (<a class="xref" href="jls-6.html#jls-6.5.3" title="6.5.3.&nbsp;Meaning of Package Names">&sect;6.5.3</a>), a type
               (<a class="xref" href="jls-6.html#jls-6.5.5" title="6.5.5.&nbsp;Meaning of Type Names">&sect;6.5.5</a>), a variable or value in an expression
               (<a class="xref" href="jls-6.html#jls-6.5.6" title="6.5.6.&nbsp;Meaning of Expression Names">&sect;6.5.6</a>), or a method
               (<a class="xref" href="jls-6.html#jls-6.5.7" title="6.5.7.&nbsp;Meaning of Method Names">&sect;6.5.7</a>).
            </p>
            <p class="note">Packages and reference types
               have <span class="emphasis"><em>members</em></span> which may be accessed by qualified
               names. As background for the discussion of qualified names and the
               determination of the meaning of names, see the descriptions of
               membership in <a class="xref" href="jls-4.html#jls-4.4" title="4.4.&nbsp;Type Variables">&sect;4.4</a>, <a class="xref" href="jls-4.html#jls-4.5.2" title="4.5.2.&nbsp;Members and Constructors of Parameterized Types">&sect;4.5.2</a>,
               <a class="xref" href="jls-4.html#jls-4.8" title="4.8.&nbsp;Raw Types">&sect;4.8</a>, <a class="xref" href="jls-4.html#jls-4.9" title="4.9.&nbsp;Intersection Types">&sect;4.9</a>,
               <a class="xref" href="jls-7.html#jls-7.1" title="7.1.&nbsp;Package Members">&sect;7.1</a>, <a class="xref" href="jls-8.html#jls-8.2" title="8.2.&nbsp;Class Members">&sect;8.2</a>,
               <a class="xref" href="jls-9.html#jls-9.2" title="9.2.&nbsp;Interface Members">&sect;9.2</a>, and <a class="xref" href="jls-10.html#jls-10.7" title="10.7.&nbsp;Array Members">&sect;10.7</a>.
            </p>
            <p class="norm"><a name="jls-6.2-300"></a>Not all identifiers in a
               program are a part of a name. Identifiers are also used in the
               following situations:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.2-300-A"></a>
                              In declarations (<a class="xref" href="jls-6.html#jls-6.1" title="6.1.&nbsp;Declarations">&sect;6.1</a>), where an identifier
                              may occur to specify the name by which the declared entity will
                              be known.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.2-300-B"></a>
                              As labels in labeled statements (<a class="xref" href="jls-14.html#jls-14.7" title="14.7.&nbsp;Labeled Statements">&sect;14.7</a>) and
                              in <code class="literal">break</code> and <code class="literal">continue</code> statements
                              (<a class="xref" href="jls-14.html#jls-14.15" title="14.15.&nbsp;The break Statement">&sect;14.15</a>, <a class="xref" href="jls-14.html#jls-14.16" title="14.16.&nbsp;The continue Statement">&sect;14.16</a>) that
                              refer to statement labels.
                     </p>
                     <p class="norm"><a name="jls-6.2-300-B.1"></a>
                              The identifiers used in labeled statements and their associated
                              <code class="literal">break</code> and <code class="literal">continue</code> statements are completely separate from
                              those used in declarations.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.2-300-C"></a>
                              In field access expressions (<a class="xref" href="jls-15.html#jls-15.11" title="15.11.&nbsp;Field Access Expressions">&sect;15.11</a>), where
                              an identifier occurs after a "<code class="literal">.</code>" token to indicate a member
                              of the object denoted by the expression before the "<code class="literal">.</code>"
                              token, or the object denoted by the <code class="literal">super</code> or
                              <span class="emphasis"><em>TypeName</em></span><code class="literal">.</code><code class="literal">super</code> before the "<code class="literal">.</code>" token.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.2-300-D"></a>
                              In some method invocation expressions
                              (<a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>), wherever an identifier occurs
                              after a "<code class="literal">.</code>" token and before a "<code class="literal">(</code>" token to indicate
                              a method to be invoked for the object denoted by the expression
                              before the "<code class="literal">.</code>" token, or the type denoted by the <span class="emphasis"><em>TypeName</em></span>
                              before the "<code class="literal">.</code>" token, or the object denoted by the <code class="literal">super</code>
                              or <span class="emphasis"><em>TypeName</em></span><code class="literal">.</code><code class="literal">super</code> before the "<code class="literal">.</code>" token.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.2-300-E"></a>
                              In some method reference expressions
                              (<a class="xref" href="jls-15.html#jls-15.13" title="15.13.&nbsp;Method Reference Expressions">&sect;15.13</a>), wherever an identifier occurs
                              after a "<code class="literal">::</code>" token to indicate a method of the object
                              denoted by the expression before the "<code class="literal">::</code>" token, or
                              the type denoted by the <span class="emphasis"><em>TypeName</em></span> before the "<code class="literal">::</code>"
                              token, or the object denoted by the <code class="literal">super</code> or
                              <span class="emphasis"><em>TypeName</em></span><code class="literal">.</code><code class="literal">super</code> before the "<code class="literal">::</code>" token.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.2-300-F"></a>
                              In qualified class instance creation expressions
                              (<a class="xref" href="jls-15.html#jls-15.9" title="15.9.&nbsp;Class Instance Creation Expressions">&sect;15.9</a>), where an identifier occurs to the
                              right of the <code class="literal">new</code> token to indicate a type that is a member of
                              the compile-time type of the expression preceding the <code class="literal">new</code>
                              token.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.2-300-G"></a>
                              In element-value pairs of annotations
                              (<a class="xref" href="jls-9.html#jls-9.7.1" title="9.7.1.&nbsp;Normal Annotations">&sect;9.7.1</a>), to denote an element of the
                              corresponding annotation type.
                     </p>
                  </li>
               </ul>
            </div>
            <div class="informalexample">
               <p class="note">In this program:</p><pre class="programlisting">
class Test {
    public static void main(String[] args) {
        Class c = System.out.getClass();
        System.out.println(c.toString().length() +
                           args[0].length() + args.length);
    }
}
</pre><p class="note">the
                  identifiers <code class="literal">Test</code>, <code class="literal">main</code>, and the
                  first occurrences of <code class="literal">args</code> and <code class="literal">c</code>
                  are not names. Rather, they are identifiers used in declarations to
                  specify the names of the declared entities. The names <code class="literal">String</code>,
                  <code class="literal">Class</code>, <code class="literal">System.out.getClass</code>,
                  <code class="literal">System.out.println</code>, <code class="literal">c.toString</code>, 
                  <code class="literal">args</code>, and <code class="literal">args.length</code> appear in
                  the example.
               </p>
               <p class="note">
                  The occurrence of <code class="literal">length</code> in <code class="literal">args.length</code> is a name
                  because <code class="literal">args.length</code> is a qualified name
                  (<a class="xref" href="jls-6.html#jls-6.5.6.2" title="6.5.6.2.&nbsp;Qualified Expression Names">&sect;6.5.6.2</a>) and not a field access expression
                  (<a class="xref" href="jls-15.html#jls-15.11" title="15.11.&nbsp;Field Access Expressions">&sect;15.11</a>). A field access expression, as well as a
                  method invocation expression, a method reference expression, and a
                  qualified class instance creation expression, uses an identifier
                  rather than a name to denote the member of interest. Thus, the
                  occurrence of <code class="literal">length</code> in <code class="literal">args[0].length()</code>
                  is <span class="emphasis"><em>not</em></span> a name, but rather an identifier appearing
                  in a method invocation expression.
               </p>
            </div>
            <p class="note">
               One might wonder why these kinds of expression use an identifier
               rather than a simple name, which is after all just an identifier. The
               reason is that a simple expression name is defined in terms of the
               lexical environment; that is, a simple expression name must be in the
               scope of a variable declaration (<a class="xref" href="jls-6.html#jls-6.5.6.1" title="6.5.6.1.&nbsp;Simple Expression Names">&sect;6.5.6.1</a>). On
               the other hand, field access, qualified method invocation, method
               references, and qualified class instance creation all refer to members
               whose names are not in the lexical environment. By definition, such
               names are bound only in the context provided by the <span class="emphasis"><em>Primary</em></span> of the
               field access expression, method invocation expression, method
               reference expression, or class instance creation expression; or by the
               <code class="literal">super</code> of the field access expression, method invocation expression,
               or method reference expression; and so on. Thus, we denote such
               members with identifiers rather than simple names.
            </p>
            <p class="note">To complicate
               things further, a field access expression is not the only way to
               denote a field of an object. For parsing reasons, a qualified name is
               used to denote a field of an in-scope variable. (The variable itself
               is denoted with a simple name, alluded to above.) It is necessary for
               access control (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>) to apply to both
               denotations of a field.
            </p>
         </div>
         <div class="section" title="6.3.&nbsp;Scope of a Declaration">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-6.3"></a>6.3.&nbsp;Scope of a Declaration
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-6.3-100"></a>The <span class="emphasis"><em>scope</em></span>
               of a declaration is the region of the program within which the entity
               declared by the declaration can be referred to using a simple name,
               provided it is visible (<a class="xref" href="jls-6.html#jls-6.4.1" title="6.4.1.&nbsp;Shadowing">&sect;6.4.1</a>).
            </p>
            <p class="norm"><a name="jls-6.3-110"></a>A declaration is said to
               be <span class="emphasis"><em>in scope</em></span> at a particular point in a program if
               and only if the declaration's scope includes that point.
            </p>
            <p class="norm-static"><a name="jls-6.3-200"></a>The scope of
               the declaration of an observable (<a class="xref" href="jls-7.html#jls-7.4.3" title="7.4.3.&nbsp;Observability of a Package">&sect;7.4.3</a>) top
               level package is all observable compilation units
               (<a class="xref" href="jls-7.html#jls-7.3" title="7.3.&nbsp;Compilation Units">&sect;7.3</a>).
            </p>
            <p class="norm-static"><a name="jls-6.3-210"></a>The
               declaration of a package that is not observable is never in
               scope.
            </p>
            <p class="norm-static"><a name="jls-6.3-220"></a>The
               declaration of a subpackage is never in scope.
            </p>
            <p class="norm-static"><a name="jls-6.3-230"></a>The
               package <code class="literal">java</code> is always in scope.
            </p>
            <p class="norm-static"><a name="jls-6.3-240"></a>The scope of
               a type imported by a single-type-import declaration
               (<a class="xref" href="jls-7.html#jls-7.5.1" title="7.5.1.&nbsp;Single-Type-Import Declarations">&sect;7.5.1</a>) or a type-import-on-demand declaration
               (<a class="xref" href="jls-7.html#jls-7.5.2" title="7.5.2.&nbsp;Type-Import-on-Demand Declarations">&sect;7.5.2</a>) is all the class and interface type
               declarations (<a class="xref" href="jls-7.html#jls-7.6" title="7.6.&nbsp;Top Level Type Declarations">&sect;7.6</a>) in the compilation unit in
               which the <code class="literal">import</code> declaration appears,  as well as any
               annotations on the package declaration (if any) of the compilation
               unit .
            </p>
            <p class="norm-static"><a name="jls-6.3-250"></a>The scope of
               a member imported by a single-static-import declaration
               (<a class="xref" href="jls-7.html#jls-7.5.3" title="7.5.3.&nbsp;Single-Static-Import Declarations">&sect;7.5.3</a>) or a static-import-on-demand declaration
               (<a class="xref" href="jls-7.html#jls-7.5.4" title="7.5.4.&nbsp;Static-Import-on-Demand Declarations">&sect;7.5.4</a>) is all the class and interface type
               declarations (<a class="xref" href="jls-7.html#jls-7.6" title="7.6.&nbsp;Top Level Type Declarations">&sect;7.6</a>) in the compilation unit in
               which the <code class="literal">import</code> declaration appears,  as well as any
               annotations on the package declaration (if any) of the compilation
               unit .
            </p>
            <p class="norm-static"><a name="jls-6.3-300"></a>The scope of
               a top level type (<a class="xref" href="jls-7.html#jls-7.6" title="7.6.&nbsp;Top Level Type Declarations">&sect;7.6</a>) is all type declarations
               in the package in which the top level type is declared.
            </p>
            <p class="norm-static"><a name="jls-6.3-310"></a>The scope of
               a declaration of a member <code class="varname">m</code> declared in or
               inherited by a class type <span class="type">C</span> (<a class="xref" href="jls-8.html#jls-8.1.6" title="8.1.6.&nbsp;Class Body and Member Declarations">&sect;8.1.6</a>) is the
               entire body of <span class="type">C</span>, including any nested type declarations.
            </p>
            <p class="norm-static"><a name="jls-6.3-320"></a>The scope of
               a declaration of a member <code class="varname">m</code> declared in or
               inherited by an interface type <span class="type">I</span> (<a class="xref" href="jls-9.html#jls-9.1.4" title="9.1.4.&nbsp;Interface Body and Member Declarations">&sect;9.1.4</a>) is
               the entire body of <span class="type">I</span>, including any nested type declarations.
            </p>
            <p class="norm-static"><a name="jls-6.3-330"></a>The scope of
               an enum constant <span class="type">C</span> declared in an enum type <span class="type">T</span> is the body of <span class="type">T</span>,
               and any <code class="literal">case</code> label of a <code class="literal">switch</code> statement whose expression is of
               enum type <span class="type">T</span> (<a class="xref" href="jls-14.html#jls-14.11" title="14.11.&nbsp;The switch Statement">&sect;14.11</a>).
            </p>
            <p class="norm-static"><a name="jls-6.3-340"></a>The scope of a
               formal parameter of a method (<a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a>),
               constructor (<a class="xref" href="jls-8.html#jls-8.8.1" title="8.8.1.&nbsp;Formal Parameters">&sect;8.8.1</a>), or lambda expression
               (<a class="xref" href="jls-15.html#jls-15.27" title="15.27.&nbsp;Lambda Expressions">&sect;15.27</a>) is the entire body of the method,
               constructor, or lambda expression.
            </p>
            <p class="norm-static"><a name="jls-6.3-400"></a>The
               scope of a class's type parameter (<a class="xref" href="jls-8.html#jls-8.1.2" title="8.1.2.&nbsp;Generic Classes and Type Parameters">&sect;8.1.2</a>)
               is  the type parameter section of
               the class declaration, the type parameter section of any superclass or
               superinterface of the class declaration, and the class
               body. 
            </p>
            <p class="norm-static"><a name="jls-6.3-410"></a>The
               scope of an interface's type parameter (<a class="xref" href="jls-9.html#jls-9.1.2" title="9.1.2.&nbsp;Generic Interfaces and Type Parameters">&sect;9.1.2</a>)
               is  the type parameter section of
               the interface declaration, the type parameter section of any
               superinterface of the interface declaration, and the interface
               body. 
            </p>
            <p class="norm-static"><a name="jls-6.3-420"></a>The
               scope of a method's type parameter (<a class="xref" href="jls-8.html#jls-8.4.4" title="8.4.4.&nbsp;Generic Methods">&sect;8.4.4</a>) is
               the entire declaration of the method, including the type parameter
               section, but excluding the method
               modifiers. 
            </p>
            <p class="norm-static"><a name="jls-6.3-430"></a>The
               scope of a constructor's type parameter (<a class="xref" href="jls-8.html#jls-8.8.4" title="8.8.4.&nbsp;Generic Constructors">&sect;8.8.4</a>)
               is the entire declaration of the constructor, including the type
               parameter section, but excluding the constructor
               modifiers. 
            </p>
            <p class="norm-static"><a name="jls-6.3-500"></a>The scope of
               a local class declaration immediately enclosed by a block
               (<a class="xref" href="jls-14.html#jls-14.2" title="14.2.&nbsp;Blocks">&sect;14.2</a>) is the rest of the immediately enclosing
               block, including its own class declaration.
            </p>
            <p class="norm-static"><a name="jls-6.3-510"></a>The scope of
               a local class declaration immediately enclosed by a switch block
               statement group (<a class="xref" href="jls-14.html#jls-14.11" title="14.11.&nbsp;The switch Statement">&sect;14.11</a>) is the rest of the
               immediately enclosing switch block statement group, including its own
               class declaration.
            </p>
            <p class="norm-static"><a name="jls-6.3-520"></a>The scope of
               a local variable declaration in a block (<a class="xref" href="jls-14.html#jls-14.4" title="14.4.&nbsp;Local Variable Declaration Statements">&sect;14.4</a>)
               is the rest of the block in which the declaration appears, starting
               with its own initializer and including any further declarators to the
               right in the local variable declaration statement.
            </p>
            <p class="norm-static"><a name="jls-6.3-530"></a>The scope of
               a local variable declared in the <span class="emphasis"><em>ForInit</em></span> part of
               a basic <code class="literal">for</code> statement (<a class="xref" href="jls-14.html#jls-14.14.1" title="14.14.1.&nbsp;The basic for Statement">&sect;14.14.1</a>) includes all
               of the following:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.3-530-A"></a>Its
                              own initializer
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.3-530-B"></a>Any
                              further declarators to the right in
                              the <span class="emphasis"><em>ForInit</em></span> part of the <code class="literal">for</code>
                              statement
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.3-530-C"></a>The <span class="emphasis"><em>Expression</em></span>
                              and <span class="emphasis"><em>ForUpdate</em></span> parts of the <code class="literal">for</code>
                              statement
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.3-530-D"></a>The
                              contained <span class="emphasis"><em>Statement</em></span></p>
                  </li>
               </ul>
            </div>
            <p class="norm-static"><a name="jls-6.3-540"></a>The scope of
               a local variable declared in the <span class="emphasis"><em>FormalParameter</em></span>
               part of an enhanced <code class="literal">for</code> statement (<a class="xref" href="jls-14.html#jls-14.14.2" title="14.14.2.&nbsp;The enhanced for statement">&sect;14.14.2</a>) is
               the contained <span class="emphasis"><em>Statement</em></span>.
            </p>
            <p class="norm-static"><a name="jls-6.3-550"></a>The scope of
               a parameter of an exception handler that is declared in a <code class="literal">catch</code>
               clause of a <code class="literal">try</code> statement (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>) is the
               entire block associated with the <code class="literal">catch</code>.
            </p>
            <p class="norm-static"><a name="jls-6.3-560"></a>The scope of a
               variable declared in the <span class="emphasis"><em>ResourceSpecification</em></span> of
               a <code class="literal">try</code>-with-resources statement (<a class="xref" href="jls-14.html#jls-14.20.3" title="14.20.3.&nbsp;try-with-resources">&sect;14.20.3</a>) is
               from the declaration rightward over the remainder of
               the <span class="emphasis"><em>ResourceSpecification</em></span> and the entire <code class="literal">try</code>
               block associated with the <code class="literal">try</code>-with-resources statement.
            </p>
            <p class="note">The translation of a <code class="literal">try</code>-with-resources statement
               implies the rule above.
            </p>
            <div class="example"><a name="d5e8585"></a><p class="title"><b>Example&nbsp;6.3-1.&nbsp;Scope of Type Declarations</b></p>
               <div class="example-contents">
                  <p class="note">These rules imply that declarations of class and
                     interface types need not appear before uses of the types. In the
                     following program, the use of <code class="literal">PointList</code> in
                     class <code class="literal">Point</code> is valid, because the scope of the
                     class declaration <code class="literal">PointList</code> includes both
                     class <code class="literal">Point</code> and class <code class="literal">PointList</code>,
                     as well as any other type declarations in other compilation units of
                     package <code class="literal">points</code>.
                  </p><pre class="programlisting">
package points;
class Point {
    int x, y;
    PointList list;
    Point next;
}

class PointList {
    Point first;
}
</pre></div>
            </div><br class="example-break"><div class="example"><a name="d5e8595"></a><p class="title"><b>Example&nbsp;6.3-2.&nbsp;Scope of Local Variable Declarations</b></p>
               <div class="example-contents">
                  <p class="note">The following program causes a compile-time error
                     because the initialization of local variable <code class="literal">x</code> is
                     within the scope of the declaration of local
                     variable <code class="literal">x</code>, but the local
                     variable <code class="literal">x</code> does not yet have a value and cannot be
                     used. The field <code class="literal">x</code> has a value of <code class="literal">0</code> (assigned
                     when <code class="literal">Test1</code> was initialized) but is a red herring
                     since it is shadowed (<a class="xref" href="jls-6.html#jls-6.4.1" title="6.4.1.&nbsp;Shadowing">&sect;6.4.1</a>) by the local
                     variable <code class="literal">x</code>.
                  </p><pre class="programlisting">
class Test1 {
    static int x;
    public static void main(String[] args) {
        int x = x;
    }
}
</pre><p class="note">The following program does compile:</p><pre class="programlisting">
class Test2 {
    static int x;
    public static void main(String[] args) {
        int x = (x=2)*2;
        System.out.println(x);
    }
}
</pre><p class="note">because the local variable <code class="literal">x</code> is
                     definitely assigned (<a class="xref" href="jls-16.html" title="Chapter&nbsp;16.&nbsp;Definite Assignment">&sect;16 (<i>Definite Assignment</i>)</a>) before it is used. It
                     prints:
                  </p><pre class="screen">
4
</pre><p class="note">In the following program, the initializer
                     for <code class="literal">three</code> can correctly refer to the
                     variable <code class="literal">two</code> declared in an earlier declarator, and
                     the method invocation in the next line can correctly refer to the
                     variable <code class="literal">three</code> declared earlier in the
                     block.
                  </p><pre class="programlisting">
class Test3 {
    public static void main(String[] args) {
        System.out.print("2+1=");
        int two = 2, three = two + 1;
        System.out.println(three);
    }
}
</pre><p class="note">This program produces the output:</p><pre class="screen">
2+1=3
</pre></div>
            </div><br class="example-break"></div>
         <div class="section" title="6.4.&nbsp;Shadowing and Obscuring">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-6.4"></a>6.4.&nbsp;Shadowing and Obscuring
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-static"><a name="jls-6.4-100"></a>A local
               variable (<a class="xref" href="jls-14.html#jls-14.4" title="14.4.&nbsp;Local Variable Declaration Statements">&sect;14.4</a>), formal parameter
               (<a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a>, <a class="xref" href="jls-15.html#jls-15.27.1" title="15.27.1.&nbsp;Lambda Parameters">&sect;15.27.1</a>),
               exception parameter (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>), and local class
               (<a class="xref" href="jls-14.html#jls-14.3" title="14.3.&nbsp;Local Class Declarations">&sect;14.3</a>) can only be referred to using a simple
               name, not a qualified name (<a class="xref" href="jls-6.html#jls-6.2" title="6.2.&nbsp;Names and Identifiers">&sect;6.2</a>).
            </p>
            <p class="norm"><a name="jls-6.4-110"></a>Some declarations are not
               permitted within the scope of a local variable, formal parameter,
               exception parameter, or local class declaration because it would be
               impossible to distinguish between the declared entities using only
               simple names.
            </p>
            <p class="note">For example, if the name of a formal parameter of a
               method could be redeclared as the name of a local variable in the
               method body, then the local variable would shadow the formal parameter
               and the formal parameter would no longer be visible - an undesirable
               outcome.
            </p>
            <p class="norm-error"><a name="jls-6.4-200"></a>It is a
               compile-time error if the name of a formal parameter
               is  used to declare a new variable within the body of the
               method, constructor, or lambda expression, unless the new variable is
               declared within a class declaration contained by the method,
               constructor, or lambda expression.
            </p>
            <p class="norm-error"><a name="jls-6.4-210"></a>It is a
               compile-time error if the name of a local variable <code class="varname">v</code>
               is  used to declare a new variable within the
               scope of <code class="varname">v</code>, unless the new variable is declared within a class whose
               declaration is within the scope of <code class="varname">v</code>.
            </p>
            <p class="norm-error"><a name="jls-6.4-220"></a>It is a
               compile-time error if the name of an exception parameter
               is  used
               to declare a new variable within the <span class="emphasis"><em>Block</em></span> of the <code class="literal">catch</code> clause,
               unless the new variable is declared within a class declaration
               contained by the <span class="emphasis"><em>Block</em></span> of the <code class="literal">catch</code> clause.
            </p>
            <p class="norm-error"><a name="jls-6.4-230"></a>It is a
               compile-time error if the name of a local class <span class="type">C</span> is  used to declare a new
               local class within the scope of <span class="type">C</span>, unless the new local class is
               declared within another class whose declaration is within the scope of
               <span class="type">C</span>.
            </p>
            <p class="note">These rules allow redeclaration of a variable or
               local class in nested class declarations (local classes
               (<a class="xref" href="jls-14.html#jls-14.3" title="14.3.&nbsp;Local Class Declarations">&sect;14.3</a>) and anonymous classes
               (<a class="xref" href="jls-15.html#jls-15.9" title="15.9.&nbsp;Class Instance Creation Expressions">&sect;15.9</a>)) that occur in the scope of the variable
               or local class. Thus, the declaration of a formal parameter, local
               variable, or local class may be shadowed in a class declaration nested
               within a method, constructor, or lambda expression; and the
               declaration of an exception parameter may be shadowed inside a class
               declaration nested within the <span class="emphasis"><em>Block</em></span> of the <code class="literal">catch</code> clause.
            </p>
            <p class="note">There are two design alternatives for handling name
               clashes created by lambda parameters and other variables declared in
               lambda expressions. One is to mimic class declarations: like local
               classes, lambda expressions introduce a new "level" for names, and all
               variable names outside the expression can be redeclared. Another is a
               "local" strategy: like <code class="literal">catch</code> clauses, <code class="literal">for</code> loops, and blocks,
               lambda expressions operate at the same "level" as the enclosing
               context, and local variables outside the expression cannot be
               shadowed. The above rules use the local strategy; there is no special
               dispensation that allows a variable declared in a lambda expression to
               shadow a variable declared in an enclosing method.
            </p>
            <p class="note">Note that the rule for local classes does not make
               an exception for a class of the same name declared within the local
               class itself. However, this case is prohibited by a separate rule: a
               class cannot have the same name as a class that encloses it
               (<a class="xref" href="jls-8.html#jls-8.1" title="8.1.&nbsp;Class Declarations">&sect;8.1</a>).
            </p>
            <div class="example"><a name="d5e8655"></a><p class="title"><b>Example&nbsp;6.4-1.&nbsp;Attempted Shadowing Of A Local Variable</b></p>
               <div class="example-contents">
                  <p class="note">Because a
                     declaration of an identifier as a local variable of a method,
                     constructor, or initializer block must not appear within the scope of
                     a parameter or local variable of the same name, a compile-time error
                     occurs for the following program:
                  </p><pre class="programlisting">
class Test1 {
    public static void main(String[] args) {
        int i;
        for (int i = 0; i &lt; 10; i++)
            System.out.println(i);
    }
}
</pre><p class="note">This restriction helps to detect some otherwise very
                     obscure bugs. A similar restriction on shadowing of members by local
                     variables was judged impractical, because the addition of a member in
                     a superclass could cause subclasses to have to rename local
                     variables. Related considerations make restrictions on shadowing of
                     local variables by members of nested classes, or on shadowing of local
                     variables by local variables declared within nested classes
                     unattractive as well.
                  </p>
                  <p class="note">Hence, the following program compiles without
                     error:
                  </p><pre class="programlisting">
class Test2 {
    public static void main(String[] args) {
        int i;
        class Local {
            {
                for (int i = 0; i &lt; 10; i++)
                    System.out.println(i);
            }
        }
        new Local();
    }
}
</pre><p class="note">On the other hand, local variables with the same
                     name may be declared in two separate blocks or <code class="literal">for</code> statements,
                     neither of which contains the other:
                  </p><pre class="programlisting">
class Test3 {
    public static void main(String[] args) {
        for (int i = 0; i &lt; 10; i++)
            System.out.print(i + " ");
        for (int i = 10; i &gt; 0; i--)
            System.out.print(i + " ");
        System.out.println();
    }
}
</pre><p class="note">This program compiles without error and, when
                     executed, produces the output:
                  </p><pre class="screen">
0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
</pre></div>
            </div><br class="example-break"><div class="section" title="6.4.1.&nbsp;Shadowing">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.4.1"></a>6.4.1.&nbsp;Shadowing
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-static"><a name="jls-6.4.1-100"></a>Some
                  declarations may be <span class="emphasis"><em>shadowed</em></span> in part of their
                  scope by another declaration of the same name, in which case a simple
                  name cannot be used to refer to the declared entity.
               </p>
               <p class="norm"><a name="jls-6.4.1-110"></a>Shadowing is distinct from
                  hiding (<a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a>, <a class="xref" href="jls-8.html#jls-8.4.8.2" title="8.4.8.2.&nbsp;Hiding (by Class Methods)">&sect;8.4.8.2</a>,
                  <a class="xref" href="jls-8.html#jls-8.5" title="8.5.&nbsp;Member Type Declarations">&sect;8.5</a>, <a class="xref" href="jls-9.html#jls-9.3" title="9.3.&nbsp;Field (Constant) Declarations">&sect;9.3</a>,
                  <a class="xref" href="jls-9.html#jls-9.5" title="9.5.&nbsp;Member Type Declarations">&sect;9.5</a>), which applies only to members which would
                  otherwise be inherited but are not because of a declaration in a
                  subclass. Shadowing is also distinct from obscuring
                  (<a class="xref" href="jls-6.html#jls-6.4.2" title="6.4.2.&nbsp;Obscuring">&sect;6.4.2</a>).
               </p>
               <p class="norm"><a name="jls-6.4.1-200"></a>A declaration <span class="type">d</span>
                  is said to be <span class="emphasis"><em>visible at point <code class="varname">p</code> in a
                        program</em></span> if the scope of <span class="type">d</span>
                  includes <code class="varname">p</code>, and <span class="type">d</span> is not shadowed by
                  any other declaration at <code class="varname">p</code>.
               </p>
               <p class="norm"><a name="jls-6.4.1-210"></a>When the program point we are
                  discussing is clear from context, we will often simply say that a
                  declaration is <span class="emphasis"><em>visible</em></span>.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-300"></a>A
                  declaration <span class="type">d</span> of a type named <span class="type">n</span> shadows the
                  declarations of any other types named <span class="type">n</span> that are in scope
                  at the point where <span class="type">d</span> occurs throughout the scope
                  of <span class="type">d</span>.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-310"></a>A declaration <span class="type">d</span> of a
                  field or formal parameter named <span class="type">n</span> shadows, throughout the
                  scope of <span class="type">d</span>, the declarations of any other variables
                  named <span class="type">n</span> that are in scope at the point
                  where <span class="type">d</span> occurs.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-320"></a>A declaration <span class="type">d</span> of a
                  local variable or exception parameter named <span class="type">n</span> shadows,
                  throughout the scope of <span class="type">d</span>, (a) the declarations of any
                  other fields named <span class="type">n</span> that are in scope at the point
                  where <span class="type">d</span> occurs, and (b) the declarations of any other
                  variables named <span class="type">n</span> that are in scope at the point
                  where <span class="type">d</span> occurs but are <span class="emphasis"><em>not</em></span> declared
                  in the innermost class in which <span class="type">d</span> is declared.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-330"></a>A
                  declaration <span class="type">d</span> of a method named <span class="type">n</span> shadows
                  the declarations of any other methods named <span class="type">n</span> that are in
                  an enclosing scope at the point where <span class="type">d</span> occurs throughout
                  the scope of <span class="type">d</span>.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-340"></a>A package
                  declaration never shadows any other declaration.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-400"></a>A
                  type-import-on-demand declaration never causes any other declaration
                  to be shadowed.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-410"></a>A
                  static-import-on-demand declaration never causes any other declaration
                  to be shadowed.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-420"></a>A
                  single-type-import declaration <span class="type">d</span> in a compilation
                  unit <span class="type">c</span> of package <span class="type">p</span> that imports a type
                  named <span class="type">n</span> shadows, throughout <span class="type">c</span>, the
                  declarations of:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.4.1-420-A"></a>any
                                 top level type named <span class="type">n</span> declared in another
                                 compilation unit of <span class="type">p</span></p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.4.1-420-B"></a>any
                               type named <span class="type">n</span> imported by a type-import-on-demand
                               declaration in <span class="type">c</span></p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.4.1-420-C"></a>any
                               type named <span class="type">n</span> imported by a static-import-on-demand
                               declaration in <span class="type">c</span></p>
                     </li>
                  </ul>
               </div>
               <p class="norm-static"><a name="jls-6.4.1-430"></a>A
                  single-static-import declaration <code class="varname">d</code> in a compilation
                  unit <code class="varname">c</code> of package <code class="varname">p</code> that imports
                  a field named <code class="varname">n</code> shadows the declaration of any
                  static field named <code class="varname">n</code> imported by a
                  static-import-on-demand declaration in <code class="varname">c</code>,
                  throughout <code class="varname">c</code>.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-440"></a>A
                  single-static-import declaration <code class="varname">d</code> in a compilation
                  unit <code class="varname">c</code> of package <code class="varname">p</code> that imports
                  a method named <code class="varname">n</code> with signature <span class="type">s</span>
                  shadows the declaration of any static method named <span class="type">n</span> with
                  signature <span class="type">s</span> imported by a static-import-on-demand
                  declaration in <code class="varname">c</code>,
                  throughout <code class="varname">c</code>.
               </p>
               <p class="norm-static"><a name="jls-6.4.1-450"></a>A
                  single-static-import declaration <code class="varname">d</code> in a compilation
                  unit <code class="varname">c</code> of package <code class="varname">p</code> that imports
                  a type named <span class="type">n</span> shadows, throughout <code class="varname">c</code>,
                  the declarations of:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.4.1-450-A"></a>any
                               static type named <span class="type">n</span> imported by a
                               static-import-on-demand declaration
                               in <code class="varname">c</code>;
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.4.1-450-B"></a>any
                               top level type (<a class="xref" href="jls-7.html#jls-7.6" title="7.6.&nbsp;Top Level Type Declarations">&sect;7.6</a>) named <span class="type">n</span>
                               declared in another compilation unit (<a class="xref" href="jls-7.html#jls-7.3" title="7.3.&nbsp;Compilation Units">&sect;7.3</a>)
                               of <code class="varname">p</code>;
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.4.1-450-C"></a>any
                               type named <span class="type">n</span> imported by a type-import-on-demand
                               declaration (<a class="xref" href="jls-7.html#jls-7.5.2" title="7.5.2.&nbsp;Type-Import-on-Demand Declarations">&sect;7.5.2</a>)
                               in <code class="varname">c</code>.
                        </p>
                     </li>
                  </ul>
               </div>
               <div class="example"><a name="d5e8778"></a><p class="title"><b>Example&nbsp;6.4.1-1.&nbsp;Shadowing of a Field Declaration by a Local Variable Declaration</b></p>
                  <div class="example-contents"><pre class="programlisting">
class Test {
    static int x = 1;
    public static void main(String[] args) {
        int x = 0;
        System.out.print("x=" + x);
        System.out.println(", Test.x=" + Test.x);
    }
}
</pre><p class="note">This program produces the output:</p><pre class="screen">
x=0, Test.x=1
</pre><p class="note">This program declares:</p>
                     <div class="note">
                        <ul class="note" type="disc">
                           <li class="listitem">
                              <p class="note">a class <code class="literal">Test</code></p>
                           </li>
                           <li class="listitem">
                              <p class="note">a class (<code class="literal">static</code>) variable <code class="literal">x</code>
                                     that is a member of the class <code class="literal">Test</code></p>
                           </li>
                           <li class="listitem">
                              <p class="note">a class method <code class="literal">main</code> that is a
                                     member of the class <code class="literal">Test</code></p>
                           </li>
                           <li class="listitem">
                              <p class="note">a parameter <code class="literal">args</code> of
                                     the <code class="literal">main</code> method
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="note">a local variable <code class="literal">x</code> of
                                     the <code class="literal">main</code> method
                              </p>
                           </li>
                        </ul>
                     </div>
                     <p class="note">Since the scope of a class variable includes the
                        entire body of the class (<a class="xref" href="jls-8.html#jls-8.2" title="8.2.&nbsp;Class Members">&sect;8.2</a>), the class
                        variable <code class="literal">x</code> would normally be available throughout
                        the entire body of the method <code class="literal">main</code>. In this
                        example, however, the class variable <code class="literal">x</code> is shadowed
                        within the body of the method <code class="literal">main</code> by the
                        declaration of the local variable <code class="literal">x</code>.
                     </p>
                     <p class="note">A local variable has as its scope the rest of the
                        block in which it is declared (<a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a>); in this
                        case this is the rest of the body of the <code class="literal">main</code>
                        method, namely its initializer "<code class="literal">0</code>" and the invocations
                        of <code class="literal">System.out.print</code>
                        and <code class="literal">System.out.println</code>.
                     </p>
                     <p class="note">This means that:</p>
                     <div class="note">
                        <ul class="note" type="disc">
                           <li class="listitem">
                              <p class="note">The expression <code class="literal">x</code> in the
                                     invocation of <code class="literal">print</code> refers to (denotes) the
                                     value of the local variable <code class="literal">x</code>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="note">The invocation of <code class="literal">println</code>
                                     uses a qualified name
                                     (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>) <code class="literal">Test.x</code>, which uses
                                     the class type name <code class="literal">Test</code> to access the class
                                     variable <code class="literal">x</code>, because the declaration
                                     of <code class="literal">Test.x</code> is shadowed at this point and cannot
                                     be referred to by its simple name.
                              </p>
                           </li>
                        </ul>
                     </div>
                     <p class="note">The keyword <code class="literal">this</code> can also be used to access a
                        shadowed field <code class="literal">x</code>, using the
                        form <code class="literal">this.x</code>. Indeed, this idiom typically appears
                        in constructors (<a class="xref" href="jls-8.html#jls-8.8" title="8.8.&nbsp;Constructor Declarations">&sect;8.8</a>):
                     </p><pre class="programlisting">
class Pair {
    Object first, second;
    public Pair(Object first, Object second) {
        this.first = first;
        this.second = second;
    }
}
</pre><p class="note">Here, the constructor takes parameters having the
                        same names as the fields to be initialized. This is simpler than
                        having to invent different names for the parameters and is not too
                        confusing in this stylized context. In general, however, it is
                        considered poor style to have local variables with the same names as
                        fields.
                     </p>
                  </div>
               </div><br class="example-break"><div class="example"><a name="d5e8840"></a><p class="title"><b>Example&nbsp;6.4.1-2.&nbsp;Shadowing of a Type Declaration by Another Type Declaration</b></p>
                  <div class="example-contents"><pre class="programlisting">
import java.util.*;
class Vector {
    int val[] = { 1 , 2 };
}

class Test {
    public static void main(String[] args) {
        Vector v = new Vector();
        System.out.println(v.val[0]);
    }
}
</pre><p class="note">The program compiles and prints:</p><pre class="screen">
1
</pre><p class="note">using the class <code class="literal">Vector</code> declared
                        here in preference to the generic
                        class <code class="literal">java.util.Vector</code>
                        (<a class="xref" href="jls-8.html#jls-8.1.2" title="8.1.2.&nbsp;Generic Classes and Type Parameters">&sect;8.1.2</a>) that might be imported on demand.
                     </p>
                  </div>
               </div><br class="example-break"></div>
            <div class="section" title="6.4.2.&nbsp;Obscuring">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.4.2"></a>6.4.2.&nbsp;Obscuring
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-static"><a name="jls-6.4.2-100"></a>A simple
                  name may occur in contexts where it may potentially be interpreted as
                  the name of a variable, a type, or a package. In these situations, the
                  rules of <a class="xref" href="jls-6.html#jls-6.5" title="6.5.&nbsp;Determining the Meaning of a Name">&sect;6.5</a> specify that a variable will be
                  chosen in preference to a type, and that a type will be chosen in
                  preference to a package. Thus, it is may sometimes be impossible to
                  refer to a visible type or package declaration via its simple name. We
                  say that such a declaration is <span class="emphasis"><em>obscured</em></span>.
               </p>
               <p class="norm"><a name="jls-6.4.2-110"></a>Obscuring is distinct from
                  shadowing (<a class="xref" href="jls-6.html#jls-6.4.1" title="6.4.1.&nbsp;Shadowing">&sect;6.4.1</a>) and hiding
                  (<a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a>, <a class="xref" href="jls-8.html#jls-8.4.8.2" title="8.4.8.2.&nbsp;Hiding (by Class Methods)">&sect;8.4.8.2</a>,
                  <a class="xref" href="jls-8.html#jls-8.5" title="8.5.&nbsp;Member Type Declarations">&sect;8.5</a>, <a class="xref" href="jls-9.html#jls-9.3" title="9.3.&nbsp;Field (Constant) Declarations">&sect;9.3</a>,
                  <a class="xref" href="jls-9.html#jls-9.5" title="9.5.&nbsp;Member Type Declarations">&sect;9.5</a>).
               </p>
               <p class="note">The naming conventions of <a class="xref" href="jls-6.html#jls-6.1" title="6.1.&nbsp;Declarations">&sect;6.1</a>
                  help reduce obscuring, but if it does occur, here are some notes about
                  what you can do to avoid it.
               </p>
               <p class="note">When package names occur in expressions:</p>
               <div class="note">
                  <ul class="note" type="disc">
                     <li class="listitem">
                        <p class="note">If a package name is obscured by a field
                                 declaration, then <code class="literal">import</code> declarations
                                 (<a class="xref" href="jls-7.html#jls-7.5" title="7.5.&nbsp;Import Declarations">&sect;7.5</a>) can usually be used to make
                                 available the type names declared in that package.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="note">If a package name is obscured by a declaration
                                 of a parameter or local variable, then the name of the parameter
                                 or local variable can be changed without affecting other
                                 code.
                        </p>
                     </li>
                  </ul>
               </div>
               <p class="note">The first component of a package name is normally
                  not easily mistaken for a type name, as a type name normally begins
                  with a single uppercase letter. (The Java programming language does not actually rely
                  on case distinctions to determine whether a name is a package name or
                  a type name.)
               </p>
               <p class="note">Obscuring involving class and interface type names
                  is rare. Names of fields, parameters, and local variables normally do
                  not obscure type names because they conventionally begin with a
                  lowercase letter whereas type names conventionally begin with an
                  uppercase letter.
               </p>
               <p class="note">Method names cannot obscure or be obscured by other
                  names (<a class="xref" href="jls-6.html#jls-6.5.7" title="6.5.7.&nbsp;Meaning of Method Names">&sect;6.5.7</a>).
               </p>
               <p class="note">Obscuring involving field names is rare;
                  however:
               </p>
               <div class="note">
                  <ul class="note" type="disc">
                     <li class="listitem">
                        <p class="note">If a field name obscures a package name, then an
                                 <code class="literal">import</code> declaration (<a class="xref" href="jls-7.html#jls-7.5" title="7.5.&nbsp;Import Declarations">&sect;7.5</a>) can usually be
                                 used to make available the type names declared in that
                                 package.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="note">If a field name obscures a type name, then a
                                 fully qualified name for the type can be used unless the type
                                 name denotes a local class (<a class="xref" href="jls-14.html#jls-14.3" title="14.3.&nbsp;Local Class Declarations">&sect;14.3</a>).
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="note">Field names cannot obscure method names.</p>
                     </li>
                     <li class="listitem">
                        <p class="note">If a field name is shadowed by a declaration of
                                 a parameter or local variable, then the name of the parameter or
                                 local variable can be changed without affecting other
                                 code.
                        </p>
                     </li>
                  </ul>
               </div>
               <p class="note">Obscuring involving constant names is rare:</p>
               <div class="note">
                  <ul class="note" type="disc">
                     <li class="listitem">
                        <p class="note">Constant names normally have no lowercase
                                 letters, so they will not normally obscure names of packages or
                                 types, nor will they normally shadow fields, whose names
                                 typically contain at least one lowercase letter.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="note">Constant names cannot obscure method names,
                                 because they are distinguished syntactically.
                        </p>
                     </li>
                  </ul>
               </div>
            </div>
         </div>
         <div class="section" title="6.5.&nbsp;Determining the Meaning of a Name">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-6.5"></a>6.5.&nbsp;Determining the Meaning of a Name
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm-static"><a name="jls-6.5-100"></a>The meaning
               of a name depends on the context in which it is used. The
               determination of the meaning of a name requires three steps:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.5-100-A"></a>
                              First, context causes a name syntactically to fall into one of
                              six categories: <span class="emphasis"><em>PackageName</em></span>, <span class="emphasis"><em>TypeName</em></span>, <span class="emphasis"><em>ExpressionName</em></span>,
                              <span class="emphasis"><em>MethodName</em></span>, <span class="emphasis"><em>PackageOrTypeName</em></span>, or <span class="emphasis"><em>AmbiguousName</em></span>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.5-100-B"></a>
                              Second, a name that is initially classified by its context as an
                              <span class="emphasis"><em>AmbiguousName</em></span> or as a <span class="emphasis"><em>PackageOrTypeName</em></span> is then reclassified
                              to be a <span class="emphasis"><em>PackageName</em></span>, <span class="emphasis"><em>TypeName</em></span>, or <span class="emphasis"><em>ExpressionName</em></span>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm-static"><a name="jls-6.5-100-C"></a>
                              Third, the resulting category then dictates the final
                            determination of the meaning of the name (or a compile-time error
                            if the name has no meaning).
                     </p>
                  </li>
               </ul>
            </div>
            <div id="jls-6.5-110" class="productionset"><a name="jls-6.5-110"></a>
                 
                 
               <div class="production"><a name="jls-PackageName"></a>
                      
                  <div class="lhs">PackageName:</div>
                      
                  <div class="rhs">
                           <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> <br>
                           <a href="jls-6.html#jls-PackageName" title="PackageName">PackageName</a> <code class="literal">.</code> <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a>
                         
                  </div>
                    
               </div>
               
                 
                 
               <div class="production"><a name="jls-TypeName"></a>
                      
                  <div class="lhs">TypeName:</div>
                      
                  <div class="rhs">
                           <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> <br>
                           <a href="jls-6.html#jls-PackageOrTypeName" title="PackageOrTypeName">PackageOrTypeName</a> <code class="literal">.</code> <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-PackageOrTypeName"></a>
                      
                  <div class="lhs">PackageOrTypeName:</div>
                      
                  <div class="rhs">
                           <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> <br>
                           <a href="jls-6.html#jls-PackageOrTypeName" title="PackageOrTypeName">PackageOrTypeName</a> <code class="literal">.</code> <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-ExpressionName"></a>
                      
                  <div class="lhs">ExpressionName:</div>
                      
                  <div class="rhs">
                           <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> <br>
                           <a href="jls-6.html#jls-AmbiguousName" title="AmbiguousName">AmbiguousName</a> <code class="literal">.</code> <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a>
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-MethodName"></a>
                      
                  <div class="lhs">MethodName:</div>
                      
                  <div class="rhs">
                           <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> <br>
                           
                         
                  </div>
                    
               </div>
               
                 
               <div class="production"><a name="jls-AmbiguousName"></a>
                      
                  <div class="lhs">AmbiguousName:</div>
                      
                  <div class="rhs">
                           <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a> <br>
                           <a href="jls-6.html#jls-AmbiguousName" title="AmbiguousName">AmbiguousName</a> <code class="literal">.</code> <a href="jls-3.html#jls-Identifier" title="Identifier">Identifier</a>
                         
                  </div>
                    
               </div>
               
            </div>
            <p class="note">The use of context helps to minimize name conflicts
               between entities of different kinds. Such conflicts will be rare if
               the naming conventions described in <a class="xref" href="jls-6.html#jls-6.1" title="6.1.&nbsp;Declarations">&sect;6.1</a> are
               followed. Nevertheless, conflicts may arise unintentionally as types
               developed by different programmers or different organizations
               evolve. For example, types, methods, and fields may have the same
               name. It is always possible to distinguish between a method and a
               field with the same name, since the context of a use always tells
               whether a method is intended.
            </p>
            <div class="section" title="6.5.1.&nbsp;Syntactic Classification of a Name According to Context">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.5.1"></a>6.5.1.&nbsp;Syntactic Classification of a Name According to Context
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-static"><a name="jls-6.5.1-110"></a>A name is
                  syntactically classified as a <span class="emphasis"><em>TypeName</em></span> in these contexts:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-110-A"></a>
                                 The first ten non-generic contexts
                                 (<a class="xref" href="jls-6.html#jls-6.1" title="6.1.&nbsp;Declarations">&sect;6.1</a>):
                        </p>
                        <div class="orderedlist">
                           <ol class="orderedlist" type="1">
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-A"></a>
                                    	  In a single-type-import declaration
                                    	  (<a class="xref" href="jls-7.html#jls-7.5.1" title="7.5.1.&nbsp;Single-Type-Import Declarations">&sect;7.5.1</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-B"></a>
                                    	  To the left of the <code class="literal">.</code> in a single-static-import
                                    	  declaration (<a class="xref" href="jls-7.html#jls-7.5.3" title="7.5.3.&nbsp;Single-Static-Import Declarations">&sect;7.5.3</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-C"></a>
                                    	  To the left of the <code class="literal">.</code> in a static-import-on-demand
                                    	  declaration (<a class="xref" href="jls-7.html#jls-7.5.4" title="7.5.4.&nbsp;Static-Import-on-Demand Declarations">&sect;7.5.4</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-D"></a>
                                    	  To the left of the <code class="literal">(</code> in a constructor declaration
                                    	  (<a class="xref" href="jls-8.html#jls-8.8" title="8.8.&nbsp;Constructor Declarations">&sect;8.8</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-E"></a>
                                    	  After the <code class="literal">@</code> sign in an annotation
                                    	  (<a class="xref" href="jls-9.html#jls-9.7" title="9.7.&nbsp;Annotations">&sect;9.7</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-F"></a>
                                    	  To the left of <code class="literal">.</code><code class="literal">class</code> in a class literal
                                    	  (<a class="xref" href="jls-15.html#jls-15.8.2" title="15.8.2.&nbsp;Class Literals">&sect;15.8.2</a>)
                                    	
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-G"></a>
                                    	  To the left of <code class="literal">.</code><code class="literal">this</code> in a qualified <code class="literal">this</code> expression
                                    	  (<a class="xref" href="jls-15.html#jls-15.8.4" title="15.8.4.&nbsp;Qualified this">&sect;15.8.4</a>)
                                    	
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-H"></a>
                                    	  To the left of <code class="literal">.</code><code class="literal">super</code> in a qualified superclass field
                                    	  access expression (<a class="xref" href="jls-15.html#jls-15.11.2" title="15.11.2.&nbsp;Accessing Superclass Members using super">&sect;15.11.2</a>)
                                    	
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-I"></a>
                                    	  To the left of <code class="literal">.</code><span class="emphasis"><em>Identifier</em></span> or
                                    	  <code class="literal">.</code><code class="literal">super</code><code class="literal">.</code><span class="emphasis"><em>Identifier</em></span> in a qualified method
                                    	  invocation expression (<a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-A-J"></a>
                                    	  To the left of <code class="literal">.</code><code class="literal">super</code><code class="literal">::</code> in a method
                                    	  reference expression (<a class="xref" href="jls-15.html#jls-15.13" title="15.13.&nbsp;Method Reference Expressions">&sect;15.13</a>) 
                                    	
                                 </p>
                              </li>
                           </ol>
                        </div>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-110-B"></a>
                                 As the <span class="emphasis"><em>Identifier</em></span> or dotted <span class="emphasis"><em>Identifier</em></span> sequence that
                                 constitutes any <span class="emphasis"><em>ReferenceType</em></span> (including a <span class="emphasis"><em>ReferenceType</em></span> to
                                 the left of the brackets in an array type, or to the left of the
                                 &lt; in a parameterized type, or in a non-wildcard type argument
                                 of a parameterized type, or in an <code class="literal">extends</code> or <code class="literal">super</code> clause of
                                 a wildcard type argument of a parameterized type) in the 16
                                 contexts where types are used
                                 (<a class="xref" href="jls-4.html#jls-4.11" title="4.11.&nbsp;Where Types Are Used">&sect;4.11</a>):
                        </p>
                        <div class="orderedlist">
                           <ol class="orderedlist" type="1">
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-A"></a>
                                    	   In an <code class="literal">extends</code> or <code class="literal">implements</code> clause of a class
                                    	   declaration (<a class="xref" href="jls-8.html#jls-8.1.4" title="8.1.4.&nbsp;Superclasses and Subclasses">&sect;8.1.4</a>,
                                    	   <a class="xref" href="jls-8.html#jls-8.1.5" title="8.1.5.&nbsp;Superinterfaces">&sect;8.1.5</a>, <a class="xref" href="jls-8.html#jls-8.5" title="8.5.&nbsp;Member Type Declarations">&sect;8.5</a>,
                                    	   <a class="xref" href="jls-9.html#jls-9.5" title="9.5.&nbsp;Member Type Declarations">&sect;9.5</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-B"></a>
                                    	   In an <code class="literal">extends</code> clause of an interface declaration
                                    	   (<a class="xref" href="jls-9.html#jls-9.1.3" title="9.1.3.&nbsp;Superinterfaces and Subinterfaces">&sect;9.1.3</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-C"></a>
                                    	   The return type of a method (<a class="xref" href="jls-8.html#jls-8.4" title="8.4.&nbsp;Method Declarations">&sect;8.4</a>,
                                               <a class="xref" href="jls-9.html#jls-9.4" title="9.4.&nbsp;Method Declarations">&sect;9.4</a>) (including the type of an
                                               element of an annotation type
                                               (<a class="xref" href="jls-9.html#jls-9.6.1" title="9.6.1.&nbsp;Annotation Type Elements">&sect;9.6.1</a>))
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-D"></a>
                                    	   In the <code class="literal">throws</code> clause of a method or constructor
                                               (<a class="xref" href="jls-8.html#jls-8.4.6" title="8.4.6.&nbsp;Method Throws">&sect;8.4.6</a>, <a class="xref" href="jls-8.html#jls-8.8.5" title="8.8.5.&nbsp;Constructor Throws">&sect;8.8.5</a>,
                                               <a class="xref" href="jls-9.html#jls-9.4" title="9.4.&nbsp;Method Declarations">&sect;9.4</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-E"></a>
                                    	   In an <code class="literal">extends</code> clause of a type parameter declaration of a
                                               generic class, interface, method, or constructor
                                               (<a class="xref" href="jls-8.html#jls-8.1.2" title="8.1.2.&nbsp;Generic Classes and Type Parameters">&sect;8.1.2</a>, <a class="xref" href="jls-9.html#jls-9.1.2" title="9.1.2.&nbsp;Generic Interfaces and Type Parameters">&sect;9.1.2</a>,
                                               <a class="xref" href="jls-8.html#jls-8.4.4" title="8.4.4.&nbsp;Generic Methods">&sect;8.4.4</a>,
                                               <a class="xref" href="jls-8.html#jls-8.8.4" title="8.8.4.&nbsp;Generic Constructors">&sect;8.8.4</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-F"></a>
                                    	  The type in a field declaration of a class or interface
                                              (<a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a>,
                                              <a class="xref" href="jls-9.html#jls-9.3" title="9.3.&nbsp;Field (Constant) Declarations">&sect;9.3</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-G"></a>
                                    	   The type in a formal parameter declaration of a method or
                                               constructor (<a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a>,
                                               <a class="xref" href="jls-8.html#jls-8.8.1" title="8.8.1.&nbsp;Formal Parameters">&sect;8.8.1</a>,
                                               <a class="xref" href="jls-9.html#jls-9.4" title="9.4.&nbsp;Method Declarations">&sect;9.4</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-H"></a>
                                    	   The type of the receiver parameter of a method
                                               (<a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a>)
                                    	 
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-I"></a>
                                    	   The type in a local variable declaration
                                               (<a class="xref" href="jls-14.html#jls-14.4" title="14.4.&nbsp;Local Variable Declaration Statements">&sect;14.4</a>, <a class="xref" href="jls-14.html#jls-14.14.1" title="14.14.1.&nbsp;The basic for Statement">&sect;14.14.1</a>,
                                               <a class="xref" href="jls-14.html#jls-14.14.2" title="14.14.2.&nbsp;The enhanced for statement">&sect;14.14.2</a>,
                                               <a class="xref" href="jls-14.html#jls-14.20.3" title="14.20.3.&nbsp;try-with-resources">&sect;14.20.3</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-J"></a>
                                    	   A type in an exception parameter declaration
                                               (<a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-K"></a>
                                    	   In an explicit type argument list to an explicit
                                               constructor invocation statement or class instance creation
                                               expression or  method invocation expression
                                               (<a class="xref" href="jls-8.html#jls-8.8.7.1" title="8.8.7.1.&nbsp;Explicit Constructor Invocations">&sect;8.8.7.1</a>, <a class="xref" href="jls-15.html#jls-15.9" title="15.9.&nbsp;Class Instance Creation Expressions">&sect;15.9</a>,
                                               <a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>)
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-L"></a>
                                    	   In an unqualified class instance creation expression,
                                               either as the class type to be instantiated
                                               (<a class="xref" href="jls-15.html#jls-15.9" title="15.9.&nbsp;Class Instance Creation Expressions">&sect;15.9</a>) or as the direct superclass or
                                               direct superinterface of an anonymous class to be
                                               instantiated (<a class="xref" href="jls-15.html#jls-15.9.5" title="15.9.5.&nbsp;Anonymous Class Declarations">&sect;15.9.5</a>)
                                    	 
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-M"></a>
                                    	   The element type in an array creation expression
                                              (<a class="xref" href="jls-15.html#jls-15.10.1" title="15.10.1.&nbsp;Array Creation Expressions">&sect;15.10.1</a>)
                                    	 
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-N"></a>
                                    	   The type in the cast operator of a cast expression
                                              (<a class="xref" href="jls-15.html#jls-15.16" title="15.16.&nbsp;Cast Expressions">&sect;15.16</a>)
                                    	 
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-O"></a>
                                    	   The type that follows the <code class="literal">instanceof</code> relational operator
                                               (<a class="xref" href="jls-15.html#jls-15.20.2" title="15.20.2.&nbsp;Type Comparison Operator instanceof">&sect;15.20.2</a>)
                                    	 
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.1-110-B-P"></a>
                                    	   In a method reference expression
                                    	   (<a class="xref" href="jls-15.html#jls-15.13" title="15.13.&nbsp;Method Reference Expressions">&sect;15.13</a>), as the reference type to
                                    	   search for a member method or as the class type or array
                                    	   type to construct.
                                    	 
                                 </p>
                              </li>
                           </ol>
                        </div>
                     </li>
                  </ul>
               </div>
               <div class="informalexample">
                  <p class="note">The extraction of a <span class="emphasis"><em>TypeName</em></span>
                     from the identifiers of a <span class="emphasis"><em>ReferenceType</em></span> in the 16 contexts above is
                     intended to apply recursively to all sub-terms of the <span class="emphasis"><em>ReferenceType</em></span>,
                     such as its element type and any type arguments.
                  </p>
                  <p class="note">For example, suppose a field declaration uses the
                     type <code class="literal">p.q.Foo[]</code>. The brackets of the array type are
                     ignored, and the term <code class="literal">p.q.Foo</code> is extracted as a
                     dotted sequence of <span class="emphasis"><em>Identifiers</em></span> to the left of the
                     brackets in an array type, and classified as a <span class="emphasis"><em>TypeName</em></span>. A later
                     step determines which of <code class="literal">p</code>, <code class="literal">q</code>,
                     and <code class="literal">Foo</code> is a type name or a package name.
                  </p>
                  <p class="note">As another example, suppose a cast operator uses the
                     type <code class="literal">p.q.Foo&lt;? extends String&gt;</code>. The term
                     <code class="literal">p.q.Foo</code> is again extracted as a dotted sequence of
                     <span class="emphasis"><em>Identifier</em></span> terms, this time to the left of the <code class="literal">&lt;</code> in a
                     parameterized type, and classified as a <span class="emphasis"><em>TypeName</em></span>. The term <code class="literal">String</code>
                     is extracted as an <span class="emphasis"><em>Identifier</em></span> in an <code class="literal">extends</code> clause of a wildcard
                     type argument of a parameterized type, and classified as a
                     <span class="emphasis"><em>TypeName</em></span>.
                  </p>
               </div>
               <p class="norm-static"><a name="jls-6.5.1-120"></a>A name is
                  syntactically classified as an <span class="emphasis"><em>ExpressionName</em></span> in
                  these contexts:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-120-A"></a>
                                 As the qualifying expression in a qualified superclass
                                 constructor invocation (<a class="xref" href="jls-8.html#jls-8.8.7.1" title="8.8.7.1.&nbsp;Explicit Constructor Invocations">&sect;8.8.7.1</a>)
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-120-B"></a>
                                 As the qualifying expression in a qualified class instance
                                 creation expression (<a class="xref" href="jls-15.html#jls-15.9" title="15.9.&nbsp;Class Instance Creation Expressions">&sect;15.9</a>)
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-120-C"></a>
                                 As the array reference expression in an array access expression
                                 (<a class="xref" href="jls-15.html#jls-15.10.3" title="15.10.3.&nbsp;Array Access Expressions">&sect;15.10.3</a>)
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-120-D"></a>
                                 As a <span class="emphasis"><em>PostfixExpression</em></span>
                                 (<a class="xref" href="jls-15.html#jls-15.14" title="15.14.&nbsp;Postfix Expressions">&sect;15.14</a>)
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-120-E"></a>
                                 As the left-hand operand of an assignment operator
                                 (<a class="xref" href="jls-15.html#jls-15.26" title="15.26.&nbsp;Assignment Operators">&sect;15.26</a>)
                        </p>
                     </li>
                  </ul>
               </div>
               <p class="norm-static"><a name="jls-6.5.1-130"></a>A name is
                  syntactically classified as a <span class="emphasis"><em>MethodName</em></span> in this context:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-130-A"></a>
                                 Before the "<code class="literal">(</code>" in a method invocation expression
                                 (<a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>)
                        </p>
                     </li>
                  </ul>
               </div>
               <p class="norm-static"><a name="jls-6.5.1-140"></a>A name is
                  syntactically classified as a <span class="emphasis"><em>PackageOrTypeName</em></span> in these
                  contexts:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-140-A"></a>
                                 To the left of the "<code class="literal">.</code>" in a qualified <span class="emphasis"><em>TypeName</em></span></p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-140-B"></a>
                                 In a type-import-on-demand declaration
                                 (<a class="xref" href="jls-7.html#jls-7.5.2" title="7.5.2.&nbsp;Type-Import-on-Demand Declarations">&sect;7.5.2</a>)
                        </p>
                     </li>
                  </ul>
               </div>
               <p class="norm-static"><a name="jls-6.5.1-150"></a>A name is
                  syntactically classified as an <span class="emphasis"><em>AmbiguousName</em></span> in these
                  contexts:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-150-A"></a>
                                 To the left of the "<code class="literal">.</code>" in a qualified <span class="emphasis"><em>ExpressionName</em></span></p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-150-B"></a>
                                 To the left of the rightmost <code class="literal">.</code> that occurs before the
                                 "<code class="literal">(</code>" in a method invocation expression
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-150-C"></a>
                                 To the left of the "<code class="literal">.</code>" in a qualified <span class="emphasis"><em>AmbiguousName</em></span></p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-150-D"></a>
                                 In the default value clause of an annotation type element
                                 declaration (<a class="xref" href="jls-9.html#jls-9.6.2" title="9.6.2.&nbsp;Defaults for Annotation Type Elements">&sect;9.6.2</a>)
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-150-E"></a>
                                 To the right of an "<code class="literal">=</code>" in an an element-value pair
                                 (<a class="xref" href="jls-9.html#jls-9.7.1" title="9.7.1.&nbsp;Normal Annotations">&sect;9.7.1</a>)
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.1-120-F"></a>
                                 To the left of <code class="literal">::</code> in a method reference expression
                                 (<a class="xref" href="jls-15.html#jls-15.13" title="15.13.&nbsp;Method Reference Expressions">&sect;15.13</a>)
                        </p>
                     </li>
                  </ul>
               </div>
               <p class="note">The effect of syntactic classification is to
                  restrict certain kinds of entities to certain parts of
                  expressions:
               </p>
               <div class="note">
                  <ul class="note" type="disc">
                     <li class="listitem">
                        <p class="note">The name of a field, parameter, or local
                                 variable may be used as an expression
                                 (<a class="xref" href="jls-15.html#jls-15.14.1" title="15.14.1.&nbsp;Expression Names">&sect;15.14.1</a>).
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="note">The name of a method may appear in an expression
                                 only as part of a method invocation expression
                                 (<a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>).
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="note">The name of a class or interface type may appear
                                 in an expression only as part of a class literal
                                 (<a class="xref" href="jls-15.html#jls-15.8.2" title="15.8.2.&nbsp;Class Literals">&sect;15.8.2</a>), a qualified <code class="literal">this</code> expression
                                 (<a class="xref" href="jls-15.html#jls-15.8.4" title="15.8.4.&nbsp;Qualified this">&sect;15.8.4</a>), a class instance creation
                                 expression (<a class="xref" href="jls-15.html#jls-15.9" title="15.9.&nbsp;Class Instance Creation Expressions">&sect;15.9</a>), an array creation
                                 expression (<a class="xref" href="jls-15.html#jls-15.10.1" title="15.10.1.&nbsp;Array Creation Expressions">&sect;15.10.1</a>), a cast expression
                                 (<a class="xref" href="jls-15.html#jls-15.16" title="15.16.&nbsp;Cast Expressions">&sect;15.16</a>), an <code class="literal">instanceof</code> expression
                                 (<a class="xref" href="jls-15.html#jls-15.20.2" title="15.20.2.&nbsp;Type Comparison Operator instanceof">&sect;15.20.2</a>), an enum constant
                                 (<a class="xref" href="jls-8.html#jls-8.9" title="8.9.&nbsp;Enum Types">&sect;8.9</a>), or as part of a qualified name for
                                 a field or method.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="note">The name of a package may appear in an
                                 expression only as part of a qualified name for a class or
                                 interface type.
                        </p>
                     </li>
                  </ul>
               </div>
            </div>
            <div class="section" title="6.5.2.&nbsp;Reclassification of Contextually Ambiguous Names">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.5.2"></a>6.5.2.&nbsp;Reclassification of Contextually Ambiguous Names
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-static"><a name="jls-6.5.2-100"></a>An
                  <span class="emphasis"><em>AmbiguousName</em></span> is then reclassified as follows.
               </p>
               <p class="norm-static"><a name="jls-6.5.2-110"></a>If the
                  <span class="emphasis"><em>AmbiguousName</em></span> is a simple name, consisting of a single
                  <span class="emphasis"><em>Identifier</em></span>:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.2-110-A"></a>
                                 If the <span class="emphasis"><em>Identifier</em></span> appears within the scope
                                 (<a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a>) of a local variable declaration
                                 (<a class="xref" href="jls-14.html#jls-14.4" title="14.4.&nbsp;Local Variable Declaration Statements">&sect;14.4</a>) or parameter declaration
                                 (<a class="xref" href="jls-8.html#jls-8.4.1" title="8.4.1.&nbsp;Formal Parameters">&sect;8.4.1</a>, <a class="xref" href="jls-8.html#jls-8.8.1" title="8.8.1.&nbsp;Formal Parameters">&sect;8.8.1</a>,
                                 <a class="xref" href="jls-14.html#jls-14.20" title="14.20.&nbsp;The try statement">&sect;14.20</a>) or field declaration
                                 (<a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a>) with that name, then the
                                 <span class="emphasis"><em>AmbiguousName</em></span> is reclassified as an <span class="emphasis"><em>ExpressionName</em></span>.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.2-110-B"></a>
                                 Otherwise, if a field of that name is declared in the
                                 compilation unit (<a class="xref" href="jls-7.html#jls-7.3" title="7.3.&nbsp;Compilation Units">&sect;7.3</a>) containing the
                                 <span class="emphasis"><em>Identifier</em></span> by a single-static-import declaration
                                 (<a class="xref" href="jls-7.html#jls-7.5.3" title="7.5.3.&nbsp;Single-Static-Import Declarations">&sect;7.5.3</a>), or by a static-import-on-demand
                                 declaration (<a class="xref" href="jls-7.html#jls-7.5.4" title="7.5.4.&nbsp;Static-Import-on-Demand Declarations">&sect;7.5.4</a>) then the
                                 <span class="emphasis"><em>AmbiguousName</em></span> is reclassified as an <span class="emphasis"><em>ExpressionName</em></span>. 
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.2-110-C"></a>
                                 Otherwise, if the <span class="emphasis"><em>Identifier</em></span> appears within the scope
                                 (<a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a>) of a top level class
                                 (<a class="xref" href="jls-8.html" title="Chapter&nbsp;8.&nbsp;Classes">&sect;8 (<i>Classes</i>)</a>) or interface type declaration
                                 (<a class="xref" href="jls-9.html" title="Chapter&nbsp;9.&nbsp;Interfaces">&sect;9 (<i>Interfaces</i>)</a>), a local class declaration
                                 (<a class="xref" href="jls-14.html#jls-14.3" title="14.3.&nbsp;Local Class Declarations">&sect;14.3</a>) or member type declaration
                                 (<a class="xref" href="jls-8.html#jls-8.5" title="8.5.&nbsp;Member Type Declarations">&sect;8.5</a>, <a class="xref" href="jls-9.html#jls-9.5" title="9.5.&nbsp;Member Type Declarations">&sect;9.5</a>) with that
                                 name, then the <span class="emphasis"><em>AmbiguousName</em></span> is reclassified as a
                                 <span class="emphasis"><em>TypeName</em></span>.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.2-110-D"></a>
                                 Otherwise, if a type of that name is declared in the compilation
                                 unit (<a class="xref" href="jls-7.html#jls-7.3" title="7.3.&nbsp;Compilation Units">&sect;7.3</a>) containing the <span class="emphasis"><em>Identifier</em></span>,
                                 either by a single-type-import declaration
                                 (<a class="xref" href="jls-7.html#jls-7.5.1" title="7.5.1.&nbsp;Single-Type-Import Declarations">&sect;7.5.1</a>), or by a type-import-on-demand
                                 declaration (<a class="xref" href="jls-7.html#jls-7.5.2" title="7.5.2.&nbsp;Type-Import-on-Demand Declarations">&sect;7.5.2</a>), or by a
                                 single-static-import declaration (<a class="xref" href="jls-7.html#jls-7.5.3" title="7.5.3.&nbsp;Single-Static-Import Declarations">&sect;7.5.3</a>),
                                 or by a static-import-on-demand declaration
                                 (<a class="xref" href="jls-7.html#jls-7.5.4" title="7.5.4.&nbsp;Static-Import-on-Demand Declarations">&sect;7.5.4</a>), then the <span class="emphasis"><em>AmbiguousName</em></span> is
                                 reclassified as a <span class="emphasis"><em>TypeName</em></span>.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.2-110-E"></a>
                                 Otherwise, the <span class="emphasis"><em>AmbiguousName</em></span> is reclassified as a
                                 <span class="emphasis"><em>PackageName</em></span>. A later step determines whether or not a package
                                 of that name actually exists.
                        </p>
                     </li>
                  </ul>
               </div>
               <p class="norm-static"><a name="jls-6.5.2-120"></a>If the
                  <span class="emphasis"><em>AmbiguousName</em></span> is a qualified name, consisting of a name, a "<code class="literal">.</code>",
                  and an <span class="emphasis"><em>Identifier</em></span>, then the name to the left of the "<code class="literal">.</code>" is first
                  reclassified, for it is itself an <span class="emphasis"><em>AmbiguousName</em></span>. There is then a
                  choice:
               </p>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.2-120-A"></a>
                                 If the name to the left of the "<code class="literal">.</code>" is reclassified as a
                                 <span class="emphasis"><em>PackageName</em></span>, then:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.2-120-A-A"></a>
                                    	  If there is a package whose name is the name to the left of
                                              the "<code class="literal">.</code>" and that package contains a declaration of a
                                              type whose name is the same as the <span class="emphasis"><em>Identifier</em></span>, then this
                                              <span class="emphasis"><em>AmbiguousName</em></span> is reclassified as a <span class="emphasis"><em>TypeName</em></span>.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.2-120-A-B"></a>
                                    	  Otherwise, this <span class="emphasis"><em>AmbiguousName</em></span> is reclassified as a
                                              <span class="emphasis"><em>PackageName</em></span>. A later step determines whether or not a
                                              package of that name actually exists.
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.2-120-B"></a>
                                 If the name to the left of the "<code class="literal">.</code>" is reclassified as a
                                 <span class="emphasis"><em>TypeName</em></span>, then:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.2-120-B-A"></a>
                                    	  If the <span class="emphasis"><em>Identifier</em></span> is the name of a method or field of the
                                              type denoted by <span class="emphasis"><em>TypeName</em></span>, this <span class="emphasis"><em>AmbiguousName</em></span> is
                                              reclassified as an <span class="emphasis"><em>ExpressionName</em></span>.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.2-120-B-B"></a>
                                    	  Otherwise, if the <span class="emphasis"><em>Identifier</em></span> is the name of a member type
                                              of the type denoted by <span class="emphasis"><em>TypeName</em></span>, this <span class="emphasis"><em>AmbiguousName</em></span> is
                                              reclassified as a <span class="emphasis"><em>TypeName</em></span>.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-error"><a name="jls-6.5.2-120-B-C"></a>
                                    	  Otherwise, a compile-time error occurs.
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.5.2-120-C"></a>
                                 If the name to the left of the "<code class="literal">.</code>" is reclassified as an
                                 <span class="emphasis"><em>ExpressionName</em></span>, then let <span class="type">T</span> be the type of the expression
                                 denoted by <span class="emphasis"><em>ExpressionName</em></span>.
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.2-120-C-A"></a>
                                    	  If the <span class="emphasis"><em>Identifier</em></span> is the name of a method or field of the
                                    	  type denoted by <span class="type">T</span>, this <span class="emphasis"><em>AmbiguousName</em></span> is reclassified as
                                    	  an <span class="emphasis"><em>ExpressionName</em></span>.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.5.2-120-C-B"></a>
                                    	  Otherwise, if the <span class="emphasis"><em>Identifier</em></span> is the name of a member type
                                    	  (<a class="xref" href="jls-8.html#jls-8.5" title="8.5.&nbsp;Member Type Declarations">&sect;8.5</a>, <a class="xref" href="jls-9.html#jls-9.5" title="9.5.&nbsp;Member Type Declarations">&sect;9.5</a>) of
                                    	  the type denoted by <span class="type">T</span>, then this <span class="emphasis"><em>AmbiguousName</em></span> is
                                    	  reclassified as a <span class="emphasis"><em>TypeName</em></span>.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-error"><a name="jls-6.5.2-120-C-C"></a>
                                    	  Otherwise, a compile-time error occurs.
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                  </ul>
               </div>
               <div class="example"><a name="d5e9321"></a><p class="title"><b>Example&nbsp;6.5.2-1.&nbsp;Reclassification of Contextually Ambiguous Names</b></p>
                  <div class="example-contents">
                     <p class="note">Consider the following contrived "library
                        code":
                     </p><pre class="programlisting">
package org.rpgpoet;
import java.util.Random;
public interface Music { Random[] wizards = new Random[4]; }
</pre><p class="note">and then consider this example code in another
                        package:
                     </p><pre class="programlisting">
package bazola;
class Gabriel {
    static int n = org.rpgpoet.Music.wizards.length;
}
</pre><p class="note">First of all, the
                        name <code class="literal">org.rpgpoet.Music.wizards.length</code> is classified
                        as an <span class="emphasis"><em>ExpressionName</em></span> because it functions as
                        a <span class="emphasis"><em>PostfixExpression</em></span>. Therefore, each of the
                        names:
                     </p><pre class="screen">
org.rpgpoet.Music.wizards
org.rpgpoet.Music
org.rpgpoet
org
</pre><p class="note">is initially classified as an <span class="emphasis"><em>AmbiguousName</em></span>. These
                        are then reclassified:
                     </p>
                     <div class="note">
                        <ul class="note" type="disc">
                           <li class="listitem">
                              <p class="note">The simple name <code class="literal">org</code> is
                                       reclassified as a <span class="emphasis"><em>PackageName</em></span> (since there
                                       is no variable or type named org in scope).
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="note">Next, assuming that there is no class or
                                       interface named <code class="literal">rpgpoet</code> in any compilation
                                       unit of package <code class="literal">org</code> (and we know that there
                                       is no such class or interface because
                                       package <code class="literal">org</code> has a subpackage
                                       named <code class="literal">rpgpoet</code>), the qualified
                                       name <code class="literal">org.rpgpoet</code> is reclassified as
                                       a <span class="emphasis"><em>PackageName</em></span>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="note">Next, because
                                       package <code class="literal">org.rpgpoet</code> has an accessible
                                       (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>) interface type
                                       named <code class="literal">Music</code>, the qualified
                                       name <code class="literal">org.rpgpoet.Music</code> is reclassified as
                                       a <span class="emphasis"><em>TypeName</em></span>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="note">Finally, because the
                                       name <code class="literal">org.rpgpoet.Music</code> is
                                       a <span class="emphasis"><em>TypeName</em></span>, the qualified
                                       name <code class="literal">org.rpgpoet.Music.wizards</code> is
                                       reclassified as an <span class="emphasis"><em>ExpressionName</em></span>.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </div>
               </div><br class="example-break"></div>
            <div class="section" title="6.5.3.&nbsp;Meaning of Package Names">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.5.3"></a>6.5.3.&nbsp;Meaning of Package Names
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-static"><a name="jls-6.5.3-100"></a>The
                  meaning of a name classified as a <span class="emphasis"><em>PackageName</em></span> is
                  determined as follows.
               </p>
               <div class="section" title="6.5.3.1.&nbsp;Simple Package Names">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.5.3.1"></a>6.5.3.1.&nbsp;Simple Package Names
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-6.5.3.1-100"></a>If a
                     package name consists of a single <span class="emphasis"><em>Identifier</em></span>, then this identifier
                     denotes a top level package named by that identifier.
                  </p>
                  <p class="norm-error"><a name="jls-6.5.3.1-110"></a>If no top
                     level package of that name is in scope (<a class="xref" href="jls-6.html#jls-6.3" title="6.3.&nbsp;Scope of a Declaration">&sect;6.3</a>),
                     then a compile-time error occurs.
                  </p>
               </div>
               <div class="section" title="6.5.3.2.&nbsp;Qualified Package Names">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.5.3.2"></a>6.5.3.2.&nbsp;Qualified Package Names
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-6.5.3.2-100"></a>If a
                     package name is of the form <code class="varname">Q.Id</code>,
                     then <code class="varname">Q</code> must also be a package name. The package
                     name <code class="varname">Q.Id</code> names a package that is the member
                     named <code class="varname">Id</code> within the package named
                     by <code class="varname">Q</code>.
                  </p>
                  <p class="norm-error"><a name="jls-6.5.3.2-110"></a>If <code class="varname">Q</code> does not name an
                     observable package (<a class="xref" href="jls-7.html#jls-7.4.3" title="7.4.3.&nbsp;Observability of a Package">&sect;7.4.3</a>),
                     or <code class="varname">Id</code> is not the simple name of an observable
                     subpackage of that package, then a compile-time error occurs.
                  </p>
               </div>
            </div>
            <div class="section" title="6.5.4.&nbsp;Meaning of PackageOrTypeNames">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.5.4"></a>6.5.4.&nbsp;Meaning of <span class="emphasis"><em>PackageOrTypeNames</em></span></h3>
                     </div>
                  </div>
               </div>
               <div class="section" title="6.5.4.1.&nbsp;Simple PackageOrTypeNames">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.5.4.1"></a>6.5.4.1.&nbsp;Simple <span class="emphasis"><em>PackageOrTypeNames</em></span></h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-6.5.4.1-100"></a>If
                     the <span class="emphasis"><em>PackageOrTypeName</em></span>, <code class="varname">Q</code>,
                     occurs in the scope of a type named <code class="varname">Q</code>, then
                     the <span class="emphasis"><em>PackageOrTypeName</em></span> is reclassified as a
                     <span class="emphasis"><em>TypeName</em></span>.
                  </p>
                  <p class="norm-static"><a name="jls-6.5.4.1-110"></a>Otherwise,
                     the <span class="emphasis"><em>PackageOrTypeName</em></span> is reclassified as a
                     <span class="emphasis"><em>PackageName</em></span>. The meaning of
                     the <span class="emphasis"><em>PackageOrTypeName</em></span> is the meaning of the
                     reclassified name.
                  </p>
               </div>
               <div class="section" title="6.5.4.2.&nbsp;Qualified PackageOrTypeNames">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.5.4.2"></a>6.5.4.2.&nbsp;Qualified <span class="emphasis"><em>PackageOrTypeNames</em></span></h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-6.5.4.2-100"></a>Given a
                     qualified <span class="emphasis"><em>PackageOrTypeName</em></span> of the form <code class="varname">Q.Id</code>, if
                     the type or package denoted by <code class="varname">Q</code> has a member type
                     named <code class="varname">Id</code>, then the qualified <span class="emphasis"><em>PackageOrTypeName</em></span>
                     name is reclassified as a <span class="emphasis"><em>TypeName</em></span>.
                  </p>
                  <p class="norm-static"><a name="jls-6.5.4.2-110"></a>Otherwise, it is reclassified as a
                     <span class="emphasis"><em>PackageName</em></span>. The meaning of the qualified <span class="emphasis"><em>PackageOrTypeName</em></span> is the
                     meaning of the reclassified name.
                  </p>
               </div>
            </div>
            <div class="section" title="6.5.5.&nbsp;Meaning of Type Names">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.5.5"></a>6.5.5.&nbsp;Meaning of Type Names
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-static"><a name="jls-6.5.5-100"></a>The
                  meaning of a name classified as a <span class="emphasis"><em>TypeName</em></span> is
                  determined as follows.
               </p>
               <div class="section" title="6.5.5.1.&nbsp;Simple Type Names">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.5.5.1"></a>6.5.5.1.&nbsp;Simple Type Names
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-error"><a name="jls-6.5.5.1-100"></a>If a type
                     name consists of a single <span class="emphasis"><em>Identifier</em></span>, then the identifier must occur
                     in the scope of exactly one visible declaration of a type with this
                     name, or a compile-time error occurs. The meaning of the type name is
                     that type.
                  </p>
               </div>
               <div class="section" title="6.5.5.2.&nbsp;Qualified Type Names">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.5.5.2"></a>6.5.5.2.&nbsp;Qualified Type Names
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-6.5.5.2-100"></a>If a
                     type name is of the form <code class="varname">Q.Id</code>,
                     then <code class="varname">Q</code> must be either a type name or a package
                     name.
                  </p>
                  <p class="norm-static"><a name="jls-6.5.5.2-110"></a>If 
                     <code class="varname">Id</code> names exactly one 
                     accessible  type (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>) that is a
                     member of the type or package denoted by <code class="varname">Q</code>, then
                     the qualified type name denotes that type.
                  </p>
                  <p class="norm-error"><a name="jls-6.5.5.2-120"></a>
                     If <code class="varname">Id</code> does not name a member type within 
                     <code class="varname">Q</code> (<a class="xref" href="jls-8.html#jls-8.5" title="8.5.&nbsp;Member Type Declarations">&sect;8.5</a>,
                     <a class="xref" href="jls-9.html#jls-9.5" title="9.5.&nbsp;Member Type Declarations">&sect;9.5</a>), or the member type named
                     <code class="varname">Id</code> within <code class="varname">Q</code> is not accessible
                     (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>), or <code class="varname">Id</code> names more than
                     one member type within <code class="varname">Q</code>, 
                     then a compile-time error occurs.
                  </p>
                  <div class="example"><a name="d5e9438"></a><p class="title"><b>Example&nbsp;6.5.5.2-1.&nbsp;Qualified Type Names</b></p>
                     <div class="example-contents"><pre class="programlisting">
class Test {
    public static void main(String[] args) {
        java.util.Date date =
            new java.util.Date(System.currentTimeMillis());
        System.out.println(date.toLocaleString());
    }
}
</pre><p class="note">This program produced the following output the first
                           time it was run:
                        </p><pre class="screen">
Sun Jan 21 22:56:29 1996
</pre><p class="note">In this example, the
                           name <code class="literal">java.util.Date</code> must denote a type, so we first
                           use the procedure recursively to determine if <code class="literal">java.util</code> is an
                           accessible type or a package, which it is, and then look to see if the
                           type <code class="literal">Date</code> is accessible in this package.
                        </p>
                     </div>
                  </div><br class="example-break"></div>
            </div>
            <div class="section" title="6.5.6.&nbsp;Meaning of Expression Names">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.5.6"></a>6.5.6.&nbsp;Meaning of Expression Names
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm-static"><a name="jls-6.5.6-100"></a>The
                  meaning of a name classified as an <span class="emphasis"><em>ExpressionName</em></span>
                  is determined as follows.
               </p>
               <div class="section" title="6.5.6.1.&nbsp;Simple Expression Names">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.5.6.1"></a>6.5.6.1.&nbsp;Simple Expression Names
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-error"><a name="jls-6.5.6.1-100"></a>If an expression name consists of
                     a single <span class="emphasis"><em>Identifier</em></span>, then there must be exactly one declaration
                     denoting either a local variable, parameter, or field visible
                     (<a class="xref" href="jls-6.html#jls-6.4.1" title="6.4.1.&nbsp;Shadowing">&sect;6.4.1</a>) at the point at which the <span class="emphasis"><em>Identifier</em></span>
                     occurs. Otherwise, a compile-time error occurs.
                  </p>
                  <p class="norm-error"><a name="jls-6.5.6.1-110"></a>If the
                     declaration denotes an instance variable (<a class="xref" href="jls-8.html#jls-8.3" title="8.3.&nbsp;Field Declarations">&sect;8.3</a>),
                     the expression name must appear within the declaration of an instance
                     method (<a class="xref" href="jls-8.html#jls-8.4" title="8.4.&nbsp;Method Declarations">&sect;8.4</a>), constructor
                     (<a class="xref" href="jls-8.html#jls-8.8" title="8.8.&nbsp;Constructor Declarations">&sect;8.8</a>), instance initializer
                     (<a class="xref" href="jls-8.html#jls-8.6" title="8.6.&nbsp;Instance Initializers">&sect;8.6</a>), or instance variable initializer
                     (<a class="xref" href="jls-8.html#jls-8.3.2" title="8.3.2.&nbsp;Field Initialization">&sect;8.3.2</a>). If the expression name appears within a
                     <code class="literal">static</code> method (<a class="xref" href="jls-8.html#jls-8.4.3.2" title="8.4.3.2.&nbsp;static Methods">&sect;8.4.3.2</a>), static initializer
                     (<a class="xref" href="jls-8.html#jls-8.7" title="8.7.&nbsp;Static Initializers">&sect;8.7</a>), or initializer for a <code class="literal">static</code> variable
                     (<a class="xref" href="jls-8.html#jls-8.3.2" title="8.3.2.&nbsp;Field Initialization">&sect;8.3.2</a>, <a class="xref" href="jls-12.html#jls-12.4.2" title="12.4.2.&nbsp;Detailed Initialization Procedure">&sect;12.4.2</a>), then a
                     compile-time error occurs.
                  </p>
                  <p class="norm-static"><a name="jls-6.5.6.1-200"></a>If the
                     declaration declares a <code class="literal">final</code>  variable which
                     is definitely assigned before the simple expression, the
                     meaning of the name is the value of
                     that variable. Otherwise, the meaning of the expression
                     name is the variable declared by the declaration.
                  </p>
                  <p class="norm-static"><a name="jls-6.5.6.1-210"></a>If the
                     expression name appears in an assignment context, invocation context,
                     or casting context, then the type of the expression name is the
                     declared type of the field, local variable, or parameter after capture
                     conversion (<a class="xref" href="jls-5.html#jls-5.1.10" title="5.1.10.&nbsp;Capture Conversion">&sect;5.1.10</a>).
                  </p>
                  <p class="norm-static"><a name="jls-6.5.6.1-220"></a>Otherwise, the type of the expression name is
                     the declared type of the field, local variable or parameter.
                  </p>
                  <p class="note">That is, if the expression name appears "on the
                     right hand side", its type is subject to capture conversion. If the
                     expression name is a variable that appears "on the left hand side",
                     its type is not subject to capture conversion.
                  </p>
                  <div class="example"><a name="d5e9475"></a><p class="title"><b>Example&nbsp;6.5.6.1-1.&nbsp;Simple Expression Names</b></p>
                     <div class="example-contents"><pre class="programlisting">
class Test {
    static int v;
    static final int f = 3;
    public static void main(String[] args) {
        int i;
        i = 1;
        v = 2;
        f = 33;  // compile-time error
        System.out.println(i + " " + v + " " + f);
    }
}
</pre><p class="note">In this program, the names used as the
                           left-hand-sides in the assignments
                           to <code class="literal">i</code>, <code class="literal">v</code>,
                           and <code class="literal">f</code> denote the local
                           variable <code class="literal">i</code>, the field <code class="literal">v</code>, and the
                           value of <code class="literal">f</code> (not the variable <code class="literal">f</code>,
                           because <code class="literal">f</code> is a <code class="literal">final</code> variable). The example
                           therefore produces an error at compile time because the last
                           assignment does not have a variable as its left-hand side. If the
                           erroneous assignment is removed, the modified code can be compiled and
                           it will produce the output:
                        </p><pre class="screen">
1 2 3
</pre></div>
                  </div><br class="example-break"></div>
               <div class="section" title="6.5.6.2.&nbsp;Qualified Expression Names">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.5.6.2"></a>6.5.6.2.&nbsp;Qualified Expression Names
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-6.5.6.2-100"></a>
                     If an expression name is of the form <code class="varname">Q.Id</code>,
                     then <code class="varname">Q</code> has already been classified as a package
                     name, a type name, or an expression name.
                  </p>
                  <p class="norm-error"><a name="jls-6.5.6.2-200"></a>
                     If <code class="varname">Q</code> is a package name, then a compile-time error
                     occurs.
                  </p>
                  <p class="norm-static"><a name="jls-6.5.6.2-210"></a>If <code class="varname">Q</code> is a type name that
                     names a class type (<a class="xref" href="jls-8.html" title="Chapter&nbsp;8.&nbsp;Classes">&sect;8 (<i>Classes</i>)</a>), then:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-error"><a name="jls-6.5.6.2-210-A"></a>
                                    If there is not exactly one accessible
                                    (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>) member of the class type that is a
                                    field named <code class="varname">Id</code>, then a compile-time error
                                    occurs.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-error"><a name="jls-6.5.6.2-210-B"></a>
                                    Otherwise, if the single accessible member field is not a class
                                    variable (that is, it is not declared <code class="literal">static</code>), then a
                                    compile-time error occurs.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.5.6.2-210-C"></a>
                                    Otherwise, if the class variable is declared <code class="literal">final</code>,
                                    then <code class="varname">Q.Id</code> denotes the value of the class
                                    variable.
                           </p>
                           <p class="norm-static"><a name="jls-6.5.6.2-210-C.1"></a>
                                    The type of the expression <code class="varname">Q.Id</code> is the
                                    declared type of the class variable after capture conversion
                                    (<a class="xref" href="jls-5.html#jls-5.1.10" title="5.1.10.&nbsp;Capture Conversion">&sect;5.1.10</a>).
                           </p>
                           <p class="norm-error"><a name="jls-6.5.6.2-210-C.2"></a>
                                    If <code class="varname">Q.Id</code> appears in a context that requires a
                                    variable and not a value, then a compile-time error
                                    occurs.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.5.6.2-210-D"></a>
                                    Otherwise, <code class="varname">Q.Id</code> denotes the class
                                    variable.
                           </p>
                           <p class="norm-static"><a name="jls-6.5.6.2-210-D.1"></a>
                                    The type of the expression <code class="varname">Q.Id</code> is the
                                    declared type of the class variable after capture conversion
                                    (<a class="xref" href="jls-5.html#jls-5.1.10" title="5.1.10.&nbsp;Capture Conversion">&sect;5.1.10</a>).
                           </p>
                           <p class="note">Note that this clause covers the use of <code class="literal">enum</code>
                                    constants (<a class="xref" href="jls-8.html#jls-8.9" title="8.9.&nbsp;Enum Types">&sect;8.9</a>), since these always have a
                                    corresponding <code class="literal">final</code> class variable.
                           </p>
                        </li>
                     </ul>
                  </div>
                  <p class="norm-static"><a name="jls-6.5.6.2-220"></a>
                     If <code class="varname">Q</code> is a type name that names an interface type
                     (<a class="xref" href="jls-9.html" title="Chapter&nbsp;9.&nbsp;Interfaces">&sect;9 (<i>Interfaces</i>)</a>), then:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-error"><a name="jls-6.5.6.2-220-A"></a>
                                    If there is not exactly one accessible
                                    (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>) member of the interface type that is
                                    a field named <code class="varname">Id</code>, then a compile-time error
                                    occurs.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.5.6.2-220-B"></a>
                                    Otherwise, <code class="varname">Q.Id</code> denotes the value of the
                                    field.
                           </p>
                           <p class="norm-static"><a name="jls-6.5.6.2-220-B.1"></a>
                                    The type of the expression <code class="varname">Q.Id</code> is the
                                    declared type of the field after capture conversion
                                    (<a class="xref" href="jls-5.html#jls-5.1.10" title="5.1.10.&nbsp;Capture Conversion">&sect;5.1.10</a>).
                           </p>
                           <p class="norm-error"><a name="jls-6.5.6.2-220-B.2"></a>
                                    If <code class="varname">Q.Id</code> appears in a context that requires a
                                    variable and not a value, then a compile-time error
                                    occurs.
                           </p>
                        </li>
                     </ul>
                  </div>
                  <p class="norm-static"><a name="jls-6.5.6.2-230"></a>
                     If <code class="varname">Q</code> is an expression name, let <span class="type">T</span> be the type of
                     the expression <code class="varname">Q</code>:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-error"><a name="jls-6.5.6.2-230-A"></a>
                                    If <span class="type">T</span> is not a reference type, a compile-time error
                                    occurs.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-error"><a name="jls-6.5.6.2-230-B"></a>
                                    If there is not exactly one accessible
                                    (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>) member of the type <span class="type">T</span> that is a
                                    field named <code class="varname">Id</code>, then a compile-time error
                                    occurs.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.5.6.2-230-C"></a>
                                    Otherwise, if this field is any of the following:
                           </p>
                           <div class="norm">
                              <ul class="norm" type="circle">
                                 <li class="listitem">
                                    <p class="norm-static"><a name="jls-6.5.6.2-230-C-A"></a>
                                       	  A field of an interface type
                                    </p>
                                 </li>
                                 <li class="listitem">
                                    <p class="norm-static"><a name="jls-6.5.6.2-230-C-B"></a>
                                       	  A <code class="literal">final</code> field of a class type (which may be either a class
                                                 variable or an instance variable)
                                    </p>
                                 </li>
                                 <li class="listitem">
                                    <p class="norm-static"><a name="jls-6.5.6.2-230-C-C"></a>
                                       	  The <code class="literal">final</code> field <code class="literal">length</code> of an array type
                                                 (<a class="xref" href="jls-10.html#jls-10.7" title="10.7.&nbsp;Array Members">&sect;10.7</a>)
                                    </p>
                                 </li>
                              </ul>
                           </div>
                           <p class="norm-static"><a name="jls-6.5.6.2-230-C.1"></a>
                                    then <code class="varname">Q.Id</code> denotes the value of the
                                    field, unless it appears in a context that requires a
                                    variable and the field is a definitely unassigned blank <code class="literal">final</code>
                                    field, in which case it yields a variable.
                           </p>
                           <p class="norm-static"><a name="jls-6.5.6.2-230-C.2"></a>
                                    The type of the expression <code class="varname">Q.Id</code> is the
                                    declared type of the field after capture conversion
                                    (<a class="xref" href="jls-5.html#jls-5.1.10" title="5.1.10.&nbsp;Capture Conversion">&sect;5.1.10</a>).
                           </p>
                           <p class="norm-error"><a name="jls-6.5.6.2-230-C.3"></a>
                                    If <code class="varname">Q.Id</code> appears in a context that requires a
                                    variable and not a value, and the field denoted
                                    by <code class="varname">Q.Id</code> is definitely assigned,
                                    then a compile-time error occurs.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.5.6.2-230-D"></a>
                                    Otherwise, <code class="varname">Q.Id</code> denotes a variable, the
                                    field <code class="varname">Id</code> of class <span class="type">T</span>, which may be either a
                                    class variable or an instance variable.
                           </p>
                           <p class="norm-static"><a name="jls-6.5.6.2-230-D.1"></a>
                                    The type of the expression <code class="varname">Q.Id</code> is the type
                                    of the field member after capture conversion
                                    (<a class="xref" href="jls-5.html#jls-5.1.10" title="5.1.10.&nbsp;Capture Conversion">&sect;5.1.10</a>).
                           </p>
                        </li>
                     </ul>
                  </div>
                  <div class="example"><a name="d5e9585"></a><p class="title"><b>Example&nbsp;6.5.6.2-1.&nbsp;Qualified Expression Names</b></p>
                     <div class="example-contents"><pre class="programlisting">
class Point {
    int x, y;
    static int nPoints;
}

class Test {
    public static void main(String[] args) {
        int i = 0;
        i.x++;        // compile-time error
        Point p = new Point();
        p.nPoints();  // compile-time error
    }
}
</pre><p class="note">This program encounters two compile-time errors,
                           because the <code class="literal">int</code> variable <code class="literal">i</code> has no members, and
                           because <code class="literal">nPoints</code> is not a method of
                           class <code class="literal">Point</code>.
                        </p>
                     </div>
                  </div><br class="example-break"><div class="example"><a name="d5e9593"></a><p class="title"><b>Example&nbsp;6.5.6.2-2.&nbsp;Qualifying an Expression with a Type Name</b></p>
                     <div class="example-contents">
                        <p class="note">Note that expression names may be qualified by type
                           names, but not by types in general. A consequence is that it is not
                           possible to access a class variable through a parameterized type. For
                           example, given the code:
                        </p><pre class="programlisting">

class Foo&lt;T&gt; {
    public static int classVar = 42;
}

</pre><p class="note">the following assignment is illegal:</p><pre class="programlisting">

Foo&lt;String&gt;.classVar = 91; // illegal

</pre><p class="note">Instead, one writes:</p><pre class="programlisting">

Foo.classVar = 91;

</pre><p class="note">This does not restrict the Java programming language in any
                           meaningful way. Type parameters may not be used in the types of static
                           variables, and so the type arguments of a parameterized type can never
                           influence the type of a static variable. Therefore, no expressive
                           power is lost. The type name <code class="literal">Foo</code> appears to be a
                           raw type, but it is not; rather, it is the name of the non-generic
                           type <code class="literal">Foo</code> whose static member is to be accessed
                           (<a class="xref" href="jls-6.html#jls-6.1" title="6.1.&nbsp;Declarations">&sect;6.1</a>). Since there is no use of a raw type,
                           there are no unchecked warnings.
                        </p>
                     </div>
                  </div><br class="example-break"></div>
            </div>
            <div class="section" title="6.5.7.&nbsp;Meaning of Method Names">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.5.7"></a>6.5.7.&nbsp;Meaning of Method Names
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm"><a name="jls-6.5.7-100"></a>The meaning of a name
                  classified as a <span class="emphasis"><em>MethodName</em></span> is determined as follows.
               </p>
               <div class="section" title="6.5.7.1.&nbsp;Simple Method Names">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.5.7.1"></a>6.5.7.1.&nbsp;Simple Method Names
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-6.5.7.1-100"></a>A simple
                     method name appears in the context of a method invocation expression
                     (<a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>). The simple method name consists of a
                     single <span class="emphasis"><em>Identifier</em></span> which specifies the name of the method to be
                     invoked. The rules of method invocation require that the <span class="emphasis"><em>Identifier</em></span>
                     either denotes a method that is visible at the point of the method
                     invocation, or denotes a method imported by a single-static-import
                     declaration or static-import-on-demand declaration
                     (<a class="xref" href="jls-7.html#jls-7.5.3" title="7.5.3.&nbsp;Single-Static-Import Declarations">&sect;7.5.3</a>, <a class="xref" href="jls-7.html#jls-7.5.4" title="7.5.4.&nbsp;Static-Import-on-Demand Declarations">&sect;7.5.4</a>).
                  </p>
                  <div class="example"><a name="d5e9617"></a><p class="title"><b>Example&nbsp;6.5.7.1-1.&nbsp;Simple Method Names and Visibility</b></p>
                     <div class="example-contents">
                        <p class="note">The following program demonstrates the role of
                           method visibility when determining which method to invoke.
                        </p><pre class="programlisting">
class Super {
    void f2(String s)       {}
    void f3(String s)       {}
    void f3(int i1, int i2) {}
}

class Test {
    void f1(int i) {}
    void f2(int i) {}
    void f3(int i) {}

    void m() {
        new Super() {
            {
                f1(0);  // OK, resolves to Test.f1(int)
                f2(0);  // compile-time error
                f3(0);  // compile-time error
            }
        };
    }
}
</pre><p class="note">For the invocation <code class="literal">f1(0)</code>, only
                           one method named <code class="literal">f1</code> is visible. It is the
                           method <code class="literal">Test.f1(int)</code>, whose declaration is in scope
                           throughout the body of <code class="literal">Test</code> including the anonymous
                           class declaration. <a class="xref" href="jls-15.html#jls-15.12.1" title="15.12.1.&nbsp;Compile-Time Step 1: Determine Class or Interface to Search">&sect;15.12.1</a> chooses to search in
                           class <code class="literal">Test</code> since the anonymous class declaration
                           has no member named <code class="literal">f1</code>. Eventually,
                           <code class="literal">Test.f1(int)</code> is resolved.
                        </p>
                        <p class="note">For the invocation <code class="literal">f2(0)</code>, two
                           methods named <code class="literal">f2</code> are visible. First, the
                           declaration of the method <code class="literal">Super.f2(String)</code> is in
                           scope throughout the anonymous class declaration. Second, the
                           declaration of the method <code class="literal">Test.f2(int)</code> is in scope
                           throughout the body of <code class="literal">Test</code> including the anonymous
                           class declaration. <a class="xref" href="jls-15.html#jls-15.12.1" title="15.12.1.&nbsp;Compile-Time Step 1: Determine Class or Interface to Search">&sect;15.12.1</a> chooses to search in
                           class <code class="literal">Super</code> because it has a member
                           named <code class="literal">f2</code>. However, <code class="literal">Super.f2(String)</code>
                           is not applicable to <code class="literal">f2(0)</code>, so a compile-time error
                           occurs. Note that class <code class="literal">Test</code> is not
                           searched.
                        </p>
                        <p class="note">For the invocation <code class="literal">f3(0)</code>, three
                           methods named <code class="literal">f3</code> are visible. First and second, the
                           declarations of the methods <code class="literal">Super.f3(String)</code>
                           and <code class="literal">Super.f3(int,int)</code> are in scope throughout the
                           anonymous class declaration. Third, the declaration of the
                           method <code class="literal">Test.f3(int)</code> is in scope throughout the body
                           of <code class="literal">Test</code> including the anonymous class
                           declaration. <a class="xref" href="jls-15.html#jls-15.12.1" title="15.12.1.&nbsp;Compile-Time Step 1: Determine Class or Interface to Search">&sect;15.12.1</a> chooses to search in
                           class <code class="literal">Super</code> because it has a member
                           named <code class="literal">f3</code>. However, <code class="literal">Super.f3(String)</code>
                           and <code class="literal">Super.f3(int,int)</code> are not applicable
                           to <code class="literal">f3(0)</code>, so a compile-time error occurs. Note that
                           class <code class="literal">Test</code> is not searched.
                        </p>
                        <p class="note">Choosing to search a nested class's superclass
                           hierarchy before the lexically enclosing scope is called the "comb
                           rule" (<a class="xref" href="jls-15.html#jls-15.12.1" title="15.12.1.&nbsp;Compile-Time Step 1: Determine Class or Interface to Search">&sect;15.12.1</a>).
                        </p>
                     </div>
                  </div><br class="example-break"></div>
            </div>
         </div>
         <div class="section" title="6.6.&nbsp;Access Control">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-6.6"></a>6.6.&nbsp;Access Control
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-6.6-100"></a>The Java programming language provides
               mechanisms for <span class="emphasis"><em>access control</em></span>, to prevent the
               users of a package or class from depending on unnecessary details of
               the implementation of that package or class. If access is permitted,
               then the accessed entity is said to
               be <span class="emphasis"><em>accessible</em></span>.
            </p>
            <p class="norm"><a name="jls-6.6-110"></a>Note that accessibility is a
               static property that can be determined at compile time; it depends
               only on types and declaration modifiers.
            </p>
            <p class="norm-static"><a name="jls-6.6-120"></a>Qualified names are a means of
               access to members of packages and reference types. When the name of
               such a member is classified from its context
               (<a class="xref" href="jls-6.html#jls-6.5.1" title="6.5.1.&nbsp;Syntactic Classification of a Name According to Context">&sect;6.5.1</a>) as a qualified type name (denoting a
               member of a package or reference type, <a class="xref" href="jls-6.html#jls-6.5.5.2" title="6.5.5.2.&nbsp;Qualified Type Names">&sect;6.5.5.2</a>)
               or a qualified expression name (denoting a member of a reference type,
               <a class="xref" href="jls-6.html#jls-6.5.6.2" title="6.5.6.2.&nbsp;Qualified Expression Names">&sect;6.5.6.2</a>), access control is applied.
            </p>
            <p class="note">For example, a
               single-type-import statement (<a class="xref" href="jls-7.html#jls-7.5.1" title="7.5.1.&nbsp;Single-Type-Import Declarations">&sect;7.5.1</a>) uses a
               qualified type name, so the named type must be accessible from the
               compilation unit containing the import statement. As another example,
               a class declaration may use a qualified type name for a superclass
               (<a class="xref" href="jls-8.html#jls-8.1.5" title="8.1.5.&nbsp;Superinterfaces">&sect;8.1.5</a>), and again the named type must be
               accessible.
            </p>
            <p class="note">
               Some obvious expressions are "missing" from context classification in
               <a class="xref" href="jls-6.html#jls-6.5.1" title="6.5.1.&nbsp;Syntactic Classification of a Name According to Context">&sect;6.5.1</a>: field access on a <span class="emphasis"><em>Primary</em></span>
               (<a class="xref" href="jls-15.html#jls-15.11.1" title="15.11.1.&nbsp;Field Access Using a Primary">&sect;15.11.1</a>), method invocation on a <span class="emphasis"><em>Primary</em></span>
               (<a class="xref" href="jls-15.html#jls-15.12" title="15.12.&nbsp;Method Invocation Expressions">&sect;15.12</a>), method reference via a <span class="emphasis"><em>Primary</em></span>
               (<a class="xref" href="jls-15.html#jls-15.13" title="15.13.&nbsp;Method Reference Expressions">&sect;15.13</a>), and the instantiated class in a
               qualified class instance creation (<a class="xref" href="jls-15.html#jls-15.9" title="15.9.&nbsp;Class Instance Creation Expressions">&sect;15.9</a>). Each
               of these expressions uses identifiers, rather than names, for the
               reason given in <a class="xref" href="jls-6.html#jls-6.2" title="6.2.&nbsp;Names and Identifiers">&sect;6.2</a>. Consequently, access
               control to members (whether fields, methods, or types) is
               applied <span class="emphasis"><em>explicitly</em></span> by field access expressions,
               method invocation expressions, method reference expressions, and
               qualified class instance creation expressions. (Note that access to a
               field may also be denoted by a qualified name occuring as a postfix
               expression.)
            </p>
            <p class="note">In addition, many
               statements and expressions allow the use of types rather than type
               names. For example, a class declaration may use a parameterized type
               (<a class="xref" href="jls-4.html#jls-4.5" title="4.5.&nbsp;Parameterized Types">&sect;4.5</a>) to denote a superclass. Because a
               parameterized type is not a qualified type name, it is necessary for
               the class declaration to explicitly perform access control for the
               denoted superclass. Consequently, most of the statements and
               expressions that provide contexts in <a class="xref" href="jls-6.html#jls-6.5.1" title="6.5.1.&nbsp;Syntactic Classification of a Name According to Context">&sect;6.5.1</a> to
               classify a <span class="emphasis"><em>TypeName</em></span> also perform their own access control
               checks.
            </p>
            <p class="note">Beyond access to
               members of a package or reference type, there is the matter of access
               to constructors of a reference type. Access control must be checked
               when a constructor is invoked explicitly or implicitly. Consequently,
               access control is checked by an explicit constructor invocation
               statement (<a class="xref" href="jls-8.html#jls-8.8.7.1" title="8.8.7.1.&nbsp;Explicit Constructor Invocations">&sect;8.8.7.1</a>) and by a class instance
               creation expression (<a class="xref" href="jls-15.html#jls-15.9.3" title="15.9.3.&nbsp;Choosing the Constructor and its Arguments">&sect;15.9.3</a>). Such checks are
               necessary because <a class="xref" href="jls-6.html#jls-6.5.1" title="6.5.1.&nbsp;Syntactic Classification of a Name According to Context">&sect;6.5.1</a> has no mention of
               explicit constructor invocation statements (because they reference
               constructor names indirectly) and is unaware of the distinction
               between the class type denoted by an unqualified class instance
               creation expression and a constructor of that class type. Also,
               constructors do not have qualified names, so we cannot rely on access
               control being checked during classification of qualified type
               names.
            </p>
            <p class="note">Accessibility affects inheritance of class members
               (<a class="xref" href="jls-8.html#jls-8.2" title="8.2.&nbsp;Class Members">&sect;8.2</a>), including hiding and method overriding
               (<a class="xref" href="jls-8.html#jls-8.4.8.1" title="8.4.8.1.&nbsp;Overriding (by Instance Methods)">&sect;8.4.8.1</a>).
            </p>
            <div class="section" title="6.6.1.&nbsp;Determining Accessibility">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.6.1"></a>6.6.1.&nbsp;Determining Accessibility
                        </h3>
                     </div>
                  </div>
               </div>
               <div class="norm">
                  <ul class="norm" type="disc">
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.6.1-100-A"></a>
                                 A package is always accessible.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.6.1-100-B"></a>
                                 If a class or interface type is declared <code class="literal">public</code>, then it may
                                 be accessed by any code, provided that the compilation unit
                                 (<a class="xref" href="jls-7.html#jls-7.3" title="7.3.&nbsp;Compilation Units">&sect;7.3</a>) in which it is declared is
                                 observable.
                        </p>
                        <p class="norm-static"><a name="jls-6.6.1-100-B.1"></a>
                                 If a class or interface type is declared with package access,
                                 then it may be accessed only from within the package in which it
                                 is declared.
                        </p>
                        <p class="norm-static"><a name="jls-6.6.1-100-B.2"></a>
                                 A class or interface type declared without an access modifier
                                 implicitly has package access.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.6.1-100-C"></a>
                                 An array type is accessible if and only if its element type is
                                 accessible.
                        </p>
                     </li>
                     <li class="listitem">
                        <p class="norm-static"><a name="jls-6.6.1-100-D"></a>
                                 A member (class, interface, field, or method) of a reference
                                 type, or a constructor of a class type, is accessible only if
                                 the type is accessible and the member or constructor is declared
                                 to permit access:
                        </p>
                        <div class="norm">
                           <ul class="norm" type="circle">
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.6.1-100-D-A"></a>
                                    	  If the member or constructor is declared <code class="literal">public</code>, then
                                              access is permitted.
                                 </p>
                                 <p class="norm-static"><a name="jls-6.6.1-100-D-A.1"></a>
                                    	  All members of interfaces lacking access modifiers are
                                              implicitly <code class="literal">public</code>.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.6.1-100-D-B"></a>
                                    	  Otherwise, if the member or constructor is declared
                                              <code class="literal">protected</code>, then access is permitted only when one of the
                                              following is true:
                                 </p>
                                 <div class="norm">
                                    <ul class="norm" type="square">
                                       <li class="listitem">
                                          <p class="norm-static"><a name="jls-6.6.1-100-D-B-A"></a>
                                             	      Access to the member or constructor occurs from within
                                                           the package containing the class in which the
                                                           <code class="literal">protected</code> member or constructor is declared.
                                          </p>
                                       </li>
                                       <li class="listitem">
                                          <p class="norm-static"><a name="jls-6.6.1-100-D-B-B"></a>
                                             	      Access is correct as described in <a class="xref" href="jls-6.html#jls-6.6.2" title="6.6.2.&nbsp;Details on protected Access">&sect;6.6.2</a>.
                                          </p>
                                       </li>
                                    </ul>
                                 </div>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.6.1-100-D-C"></a>
                                    	  Otherwise, if the member or constructor is declared with
                                    	  package access, then access is permitted only when the
                                    	  access occurs from within the package in which the type is
                                    	  declared.
                                 </p>
                                 <p class="norm-static"><a name="jls-6.6.1-100-D-C.1"></a>
                                    	  A class member or constructor declared without an access
                                    	  modifier implicitly has package access.
                                 </p>
                              </li>
                              <li class="listitem">
                                 <p class="norm-static"><a name="jls-6.6.1-100-D-D"></a>
                                    	  Otherwise, the member or constructor is declared <code class="literal">private</code>,
                                    	  and access is permitted if and only if it occurs within the
                                    	  body of the top level class (<a class="xref" href="jls-7.html#jls-7.6" title="7.6.&nbsp;Top Level Type Declarations">&sect;7.6</a>) that
                                    	  encloses the declaration of the member or constructor.
                                 </p>
                              </li>
                           </ul>
                        </div>
                     </li>
                  </ul>
               </div>
               <div class="example"><a name="d5e9731"></a><p class="title"><b>Example&nbsp;6.6-1.&nbsp;Access Control</b></p>
                  <div class="example-contents">
                     <p class="note">Consider the two compilation units:</p><pre class="programlisting">
package points;
class PointVec { Point[] vec; }
</pre><p class="note">and:</p><pre class="programlisting">
package points;
public class Point {
    protected int x, y;
    public void move(int dx, int dy) { x += dx; y += dy; }
    public int getX() { return x; }
    public int getY() { return y; }
}
</pre><p class="note">which declare two class types in the
                        package <code class="literal">points</code>:
                     </p>
                     <div class="note">
                        <ul class="note" type="disc">
                           <li class="listitem">
                              <p class="note">The class type <code class="literal">PointVec</code> is
                                       not <code class="literal">public</code> and not part of the <code class="literal">public</code> interface of the
                                       package <code class="literal">points</code>, but rather can be used only
                                       by other classes in the package.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="note">The class type <code class="literal">Point</code> is
                                       declared <code class="literal">public</code> and is available to other packages. It is part
                                       of the <code class="literal">public</code> interface of the
                                       package <code class="literal">points</code>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="note">The
                                       methods <code class="literal">move</code>, <code class="literal">getX</code>,
                                       and <code class="literal">getY</code> of the
                                       class <code class="literal">Point</code> are declared <code class="literal">public</code> and so are
                                       available to any code that uses an object of
                                       type <code class="literal">Point</code>.
                              </p>
                           </li>
                           <li class="listitem">
                              <p class="note">The fields <code class="literal">x</code>
                                       and <code class="literal">y</code> are declared <code class="literal">protected</code> and are
                                       accessible outside the package <code class="literal">points</code> only in
                                       subclasses of class <code class="literal">Point</code>, and only when they
                                       are fields of objects that are being implemented by the code
                                       that is accessing them.
                              </p>
                              <p class="note">See <a class="xref" href="jls-6.html#jls-6.6.2" title="6.6.2.&nbsp;Details on protected Access">&sect;6.6.2</a> for an example
                                       of how the <code class="literal">protected</code> access modifier limits access.
                              </p>
                           </li>
                        </ul>
                     </div>
                  </div>
               </div><br class="example-break"><div class="example"><a name="d5e9770"></a><p class="title"><b>Example&nbsp;6.6-2.&nbsp;Access to <code class="literal">public</code> Fields, Methods, and Constructors</b></p>
                  <div class="example-contents">
                     <p class="note">A <code class="literal">public</code> class member or constructor is accessible
                        throughout the package where it is declared and from any other
                        package, provided the package in which it is declared is observable
                        (<a class="xref" href="jls-7.html#jls-7.4.3" title="7.4.3.&nbsp;Observability of a Package">&sect;7.4.3</a>). For example, in the compilation
                        unit:
                     </p><pre class="programlisting">
package points;
public class Point {
    int x, y;
    public void move(int dx, int dy) {
        x += dx; y += dy;
        moves++;
    }
    public static int moves = 0;
}
</pre><p class="note">the <code class="literal">public</code> class <code class="literal">Point</code> has as
                        <code class="literal">public</code> members the <code class="literal">move</code> method and
                        the <code class="literal">moves</code> field. These <code class="literal">public</code> members are
                        accessible to any other package that has access to
                        package <code class="literal">points</code>. The fields <code class="literal">x</code>
                        and <code class="literal">y</code> are not <code class="literal">public</code> and therefore are accessible
                        only from within the package <code class="literal">points</code>.
                     </p>
                  </div>
               </div><br class="example-break"><div class="example"><a name="d5e9789"></a><p class="title"><b>Example&nbsp;6.6-3.&nbsp;Access to <code class="literal">public</code> and Non-<code class="literal">public</code> Classes</b></p>
                  <div class="example-contents">
                     <p class="note">If a class lacks the <code class="literal">public</code> modifier, access to
                        the class declaration is limited to the package in which it is
                        declared (<a class="xref" href="jls-6.html#jls-6.6" title="6.6.&nbsp;Access Control">&sect;6.6</a>). In the example:
                     </p><pre class="programlisting">
package points;
public class Point {
    public int x, y;
    public void move(int dx, int dy) { x += dx; y += dy; }
}
class PointList {
    Point next, prev;
}
</pre><p class="note">two classes are declared in the compilation
                        unit. The class <code class="literal">Point</code> is available outside the
                        package <code class="literal">points</code>, while the
                        class <code class="literal">PointList</code> is available for access only within
                        the package. Thus a compilation unit in another package can
                        access <code class="literal">points.Point</code>, either by using its fully
                        qualified name:
                     </p><pre class="programlisting">
package pointsUser;
class Test1 {
    public static void main(String[] args) {
        points.Point p = new points.Point();
        System.out.println(p.x + " " + p.y);
    }
}
</pre><p class="note">or by using a single-type-import declaration
                        (<a class="xref" href="jls-7.html#jls-7.5.1" title="7.5.1.&nbsp;Single-Type-Import Declarations">&sect;7.5.1</a>) that mentions the fully qualified name,
                        so that the simple name may be used thereafter:
                     </p><pre class="programlisting">
package pointsUser;
import points.Point;
class Test2 {
    public static void main(String[] args) {
        Point p = new Point();
        System.out.println(p.x + " " + p.y);
    }
}
</pre><p class="note">However, this compilation unit cannot use or
                        import <code class="literal">points.PointList</code>, which is not declared
                        <code class="literal">public</code> and is therefore inaccessible outside
                        package <code class="literal">points</code>.
                     </p>
                  </div>
               </div><br class="example-break"><div class="example"><a name="d5e9810"></a><p class="title"><b>Example&nbsp;6.6-4.&nbsp;Access to Package-Access Fields, Methods, and Constructors</b></p>
                  <div class="example-contents">
                     <p class="note">If none of the access modifiers <code class="literal">public</code>,
                        <code class="literal">protected</code>, or <code class="literal">private</code> are specified, a class member or constructor
                        has package access: it is accessible throughout the package that
                        contains the declaration of the class in which the class member is
                        declared, but the class member or constructor is not accessible in any
                        other package.
                     </p>
                     <p class="note">If a <code class="literal">public</code> class has a method or constructor with
                        package access, then this method or constructor is not accessible to
                        or inherited by a subclass declared outside this package.
                     </p>
                     <p class="note">For example, if we have:</p><pre class="programlisting">
package points;
public class Point {
    public int x, y;
    void move(int dx, int dy) { x += dx; y += dy; }
    public void moveAlso(int dx, int dy) { move(dx, dy); }
}
</pre><p class="note">then a subclass in another package may declare an
                        unrelated <code class="literal">move</code> method, with the same signature
                        (<a class="xref" href="jls-8.html#jls-8.4.2" title="8.4.2.&nbsp;Method Signature">&sect;8.4.2</a>) and return type. Because the
                        original <code class="literal">move</code> method is not accessible from
                        package <code class="literal">morepoints</code>, <code class="literal">super</code> may
                        not be used:
                     </p><pre class="programlisting">
package morepoints;
public class PlusPoint extends points.Point {
    public void move(int dx, int dy) {
        super.move(dx, dy);  // compile-time error
        moveAlso(dx, dy);
    }
}
</pre><p class="note">Because <code class="literal">move</code>
                        of <code class="literal">Point</code> is not overridden
                        by <code class="literal">move</code> in <code class="literal">PlusPoint</code>, the
                        method <code class="literal">moveAlso</code> in <code class="literal">Point</code> never
                        calls the method <code class="literal">move</code>
                        in <code class="literal">PlusPoint</code>. Thus if you delete
                        the <code class="literal">super.move</code> call
                        from <code class="literal">PlusPoint</code> and execute the test program:
                     </p><pre class="programlisting">
import points.Point;
import morepoints.PlusPoint;
class Test {
    public static void main(String[] args) {
        PlusPoint pp = new PlusPoint();
        pp.move(1, 1);
    }
}
</pre><p class="note">it terminates normally. If <code class="literal">move</code>
                        of <code class="literal">Point</code> were overridden by <code class="literal">move</code>
                        in <code class="literal">PlusPoint</code>, then this program would recurse
                        infinitely, until a <code class="literal">StackOverflowError</code> occurred.
                     </p>
                  </div>
               </div><br class="example-break"><div class="example"><a name="d5e9845"></a><p class="title"><b>Example&nbsp;6.6-5.&nbsp;Access to <code class="literal">private</code> Fields, Methods, and Constructors</b></p>
                  <div class="example-contents">
                     <p class="note">A <code class="literal">private</code> class member or constructor is
                        accessible only within the body of the top level class
                        (<a class="xref" href="jls-7.html#jls-7.6" title="7.6.&nbsp;Top Level Type Declarations">&sect;7.6</a>) that encloses the declaration of the
                        member or constructor. It is not inherited by subclasses. In the
                        example:
                     </p><pre class="programlisting">
class Point {
    Point() { setMasterID(); }
    int x, y;
    private int ID;
    private static int masterID = 0;
    private void setMasterID() { ID = masterID++; }
}
</pre><p class="note">the private
                        members <code class="literal">ID</code>, <code class="literal">masterID</code>,
                        and <code class="literal">setMasterID</code> may be used only within the body of
                        class <code class="literal">Point</code>. They may not be accessed by qualified
                        names, field access expressions, or method invocation expressions
                        outside the body of the declaration
                        of <code class="literal">Point</code>.
                     </p>
                     <p class="note">See <a class="xref" href="jls-8.html#jls-8.8.8" title="8.8.8.&nbsp;Constructor Overloading">&sect;8.8.8</a> for an example that
                        uses a <code class="literal">private</code> constructor.
                     </p>
                  </div>
               </div><br class="example-break"></div>
            <div class="section" title="6.6.2.&nbsp;Details on protected Access">
               <div class="titlepage">
                  <div>
                     <div>
                        <h3 class="title"><a name="jls-6.6.2"></a>6.6.2.&nbsp;Details on protected Access
                        </h3>
                     </div>
                  </div>
               </div>
               <p class="norm"><a name="jls-6.6.2-100"></a>A <code class="literal">protected</code> member or
                  constructor of an object may be accessed from outside the package in
                  which it is declared only by code that is responsible for the
                  implementation of that object.
               </p>
               <div class="section" title="6.6.2.1.&nbsp;Access to a protected Member">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.6.2.1"></a>6.6.2.1.&nbsp;Access to a <code class="literal">protected</code> Member
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-6.6.2.1-100"></a>Let <span class="type">C</span>
                     be the class in which a <code class="literal">protected</code> member is declared. Access is
                     permitted only within the body of a subclass <span class="type">S</span> of <span class="type">C</span>.
                  </p>
                  <p class="norm-static"><a name="jls-6.6.2.1-110"></a>In
                     addition, if <span class="emphasis"><em>Id</em></span> denotes an instance field or
                     instance method, then:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.6.2.1-110-A"></a>
                                    If the access is by a qualified name <code class="varname">Q.Id</code> or
                                    a method reference expression <code class="varname">Q <code class="literal">::</code>
                                       Id</code> (<a class="xref" href="jls-15.html#jls-15.13" title="15.13.&nbsp;Method Reference Expressions">&sect;15.13</a>),
                                    where <code class="varname">Q</code> is an <span class="emphasis"><em>ExpressionName</em></span>, then the
                                    access is permitted if and only if the type of the
                                    expression <code class="varname">Q</code> is <span class="type">S</span> or a subclass of
                                    <span class="type">S</span>.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.6.2.1-110-B"></a>
                                    If the access is by a field access
                                    expression <code class="varname">E.Id</code>, or a method invocation
                                    expression <code class="varname">E.Id</code><code class="literal">(...)</code>, or a
                                    method reference expression <code class="varname">E <code class="literal">::</code>
                                       Id</code>, where <code class="varname">E</code> is a <span class="emphasis"><em>Primary</em></span>
                                    expression (<a class="xref" href="jls-15.html#jls-15.8" title="15.8.&nbsp;Primary Expressions">&sect;15.8</a>), then the access is
                                    permitted if and only if the type of <code class="varname">E</code> is <span class="type">S</span>
                                    or a subclass of <span class="type">S</span>.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.6.2.1-110-C"></a>
                                    If the access is by a method reference expression
                                    <code class="varname">T <code class="literal">::</code> Id</code>, where <span class="type">T</span> is a <span class="emphasis"><em>ReferenceType</em></span>,
                                    then the access is permitted if and only if the type <span class="type">T</span> 
                                    is <span class="type">S</span> or a subclass of <span class="type">S</span>.
                           </p>
                        </li>
                     </ul>
                  </div>
                  <p class="note">More information about access to <code class="literal">protected</code> members
                     can be found in <em class="citetitle">Checking Access to Protected Members in the
                        Java Virtual Machine</em> by Alessandro Coglio, in
                     the <em class="citetitle">Journal of Object Technology</em>, October
                     2005.
                  </p>
               </div>
               <div class="section" title="6.6.2.2.&nbsp;Qualified Access to a protected Constructor">
                  <div class="titlepage">
                     <div>
                        <div>
                           <h4 class="title"><a name="jls-6.6.2.2"></a>6.6.2.2.&nbsp;Qualified Access to a <code class="literal">protected</code> Constructor
                           </h4>
                        </div>
                     </div>
                  </div>
                  <p class="norm-static"><a name="jls-6.6.2.2-100"></a>Let <span class="type">C</span>
                     be the class in which a <code class="literal">protected</code> constructor is declared and let
                     <span class="type">S</span> be the innermost class in whose declaration the use of the
                     <code class="literal">protected</code> constructor occurs. Then:
                  </p>
                  <div class="norm">
                     <ul class="norm" type="disc">
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.6.2.2-100-A"></a>
                                    If the access is by a superclass constructor invocation
                                    <code class="literal">super</code><code class="literal">(...)</code>, or a qualified superclass
                                    constructor invocation <code class="varname">E</code><code class="literal">.</code><code class="literal">super</code><code class="literal">(...)</code>,
                                    where <code class="varname">E</code> is a <span class="emphasis"><em>Primary</em></span> expression, then the
                                    access is permitted.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.6.2.2-100-B"></a>
                                    If the access is by an anonymous class instance creation
                                    expression <code class="literal">new</code> <span class="type">C</span><code class="literal">(...){...}</code>, or a
                                    qualified anonymous class instance creation expression
                                    <span class="type">E</span><code class="literal">.</code><code class="literal">new</code> <span class="type">C</span><code class="literal">(...){...}</code>, 
                                    where <span class="type">E</span> is a <span class="emphasis"><em>Primary</em></span> expression, 
                                    then the access is permitted.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="norm-static"><a name="jls-6.6.2.2-100-C"></a>
                                    If the access is by a simple class instance creation expression
                                    <code class="literal">new</code> <span class="type">C</span><code class="literal">(...)</code>, or a qualified class instance
                                    creation expression <span class="type">E</span><code class="literal">.</code><code class="literal">new</code> <span class="type">C</span><code class="literal">(...)</code>,
                                    where <span class="type">E</span> is a <span class="emphasis"><em>Primary</em></span> expression, or a method
                                    reference expression <span class="type">C</span> <code class="literal">::</code> <code class="literal">new</code>, where <span class="type">C</span> is a
                                    <span class="emphasis"><em>ClassType</em></span>, then the access is not permitted. A <code class="literal">protected</code>
                                    constructor can be accessed by a class instance creation
                                    expression (that does not declare an anonymous class) or a
                                    method reference expression only from within the package in
                                    which it is defined.
                           </p>
                        </li>
                     </ul>
                  </div>
                  <div class="example"><a name="d5e9962"></a><p class="title"><b>Example&nbsp;6.6.2-1.&nbsp;Access to <code class="literal">protected</code> Fields, Methods, and Constructors</b></p>
                     <div class="example-contents">
                        <p class="note">Consider this example, where
                           the <code class="literal">points</code> package declares:
                        </p><pre class="programlisting">
package points;
public class Point {
    protected int x, y;
    void warp(threePoint.Point3d a) {
        if (a.z &gt; 0)  // compile-time error: cannot access a.z
            a.delta(this);
    }
}
</pre><p class="note">and the <code class="literal">threePoint</code> package
                           declares:
                        </p><pre class="programlisting">
package threePoint;
import points.Point;
public class Point3d extends Point {
    protected int z;
    public void delta(Point p) {
        p.x += this.x;  // compile-time error: cannot access p.x
        p.y += this.y;  // compile-time error: cannot access p.y
    }
    public void delta3d(Point3d q) {
        q.x += this.x;
        q.y += this.y;
        q.z += this.z;
    }
}
</pre><p class="note">A compile-time error occurs in the
                           method <code class="literal">delta</code> here: it cannot access the <code class="literal">protected</code>
                           members <code class="literal">x</code> and <code class="literal">y</code> of its
                           parameter <code class="literal">p</code>, because
                           while <code class="literal">Point3d</code> (the class in which the references to
                           fields <code class="literal">x</code> and <code class="literal">y</code> occur) is a
                           subclass of <code class="literal">Point</code> (the class in
                           which <code class="literal">x</code> and <code class="literal">y</code> are declared), it
                           is not involved in the implementation of a <code class="literal">Point</code>
                           (the type of the parameter <code class="literal">p</code>). The
                           method <code class="literal">delta3d</code> can access the <code class="literal">protected</code> members
                           of its parameter <code class="literal">q</code>, because the
                           class <code class="literal">Point3d</code> is a subclass
                           of <code class="literal">Point</code> and is involved in the implementation of
                           a <code class="literal">Point3d</code>.
                        </p>
                        <p class="note">The method <code class="literal">delta</code> could try to
                           cast (<a class="xref" href="jls-5.html#jls-5.5" title="5.5.&nbsp;Casting Contexts">&sect;5.5</a>, <a class="xref" href="jls-15.html#jls-15.16" title="15.16.&nbsp;Cast Expressions">&sect;15.16</a>) its
                           parameter to be a <code class="literal">Point3d</code>, but this cast would
                           fail, causing an exception, if the class of <code class="literal">p</code> at
                           run time were not <code class="literal">Point3d</code>.
                        </p>
                        <p class="note">A compile-time error also occurs in the
                           method <code class="literal">warp</code>: it cannot access the <code class="literal">protected</code>
                           member <code class="literal">z</code> of its parameter <code class="literal">a</code>,
                           because while the class <code class="literal">Point</code> (the class in which
                           the reference to field <code class="literal">z</code> occurs) is involved in the
                           implementation of a <code class="literal">Point3d</code> (the type of the
                           parameter <code class="literal">a</code>), it is not a subclass
                           of <code class="literal">Point3d</code> (the class in which <code class="literal">z</code>
                           is declared).
                        </p>
                     </div>
                  </div><br class="example-break"></div>
            </div>
         </div>
         <div class="section" title="6.7.&nbsp;Fully Qualified Names and Canonical Names">
            <div class="titlepage">
               <div>
                  <div>
                     <h2 class="title" style="clear: both"><a name="jls-6.7"></a>6.7.&nbsp;Fully Qualified Names and Canonical Names
                     </h2>
                  </div>
               </div>
            </div>
            <p class="norm"><a name="jls-6.7-100"></a>Every primitive type, 
               named  package, top level class, and top level interface
               has a <span class="emphasis"><em>fully qualified name</em></span>:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-100-A"></a>The fully qualified name
                              of a primitive type is the keyword for that primitive type,
                              namely <code class="literal">byte</code>, <code class="literal">short</code>, <code class="literal">char</code>, <code class="literal">int</code>, <code class="literal">long</code>, <code class="literal">float</code>,
                              <code class="literal">double</code>, or <code class="literal">boolean</code>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-100-B"></a>The fully qualified name
                              of a named package that is not a subpackage of a named package
                              is its simple name.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-100-C"></a>The fully qualified name
                              of a named package that is a subpackage of another named package
                              consists of the fully qualified name of the containing package,
                              followed by "<code class="literal">.</code>", followed by the simple (member) name of the
                              subpackage.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-100-D"></a>The fully qualified name
                              of a top level class or top level interface that is declared in
                              an unnamed package is the simple name of the class or
                              interface.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-100-E"></a>The fully qualified name
                              of a top level class or top level interface that is declared in
                              a named package consists of the fully qualified name of the
                              package, followed by "<code class="literal">.</code>", followed by the simple name of the
                              class or interface.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm"><a name="jls-6.7-110"></a>Each member class, member
               interface, and array type <span class="emphasis"><em>may</em></span> have a fully
               qualified name:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-110-A"></a>A member class or member
                              interface <span class="type">M</span> of another class or interface <span class="type">C</span> has a
                              fully qualified name if and only if <span class="type">C</span> has a fully qualified
                              name.
                     </p>
                     <p class="norm"><a name="jls-6.7-110-A.1"></a>In that case, the fully
                              qualified name of <span class="type">M</span> consists of the fully qualified
                              name of <span class="type">C</span>, followed by "<code class="literal">.</code>", followed by the simple name
                              of <span class="type">M</span>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-110-B"></a>An array type has a fully
                              qualified name if and only if its element type has a fully
                              qualified name.
                     </p>
                     <p class="norm"><a name="jls-6.7-110-B.1"></a>In that case, the fully
                              qualified name of an array type consists of the fully qualified
                              name of the component type of the array type followed by
                              "<code class="literal">[]</code>".
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm"><a name="jls-6.7-120"></a>A local class does not have a
               fully qualified name.
            </p>
            <p class="norm"><a name="jls-6.7-200"></a>Every primitive type, 
               named  package, top level class, and top level interface
               has a <span class="emphasis"><em>canonical name</em></span>:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-200-A"></a>For every primitive
                             type,  named  package, top level class,
                             and top level interface, the canonical name is the same as the
                             fully qualified name.
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm"><a name="jls-6.7-210"></a>Each member class, member
               interface, and array type <span class="emphasis"><em>may</em></span> have a canonical
               name:
            </p>
            <div class="norm">
               <ul class="norm" type="disc">
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-210-A"></a>A member class or member
                            interface <span class="type">M</span> declared in another class or interface
                            <span class="type">C</span> has a canonical name if and only if <span class="type">C</span> has a canonical
                            name.
                     </p>
                     <p class="norm"><a name="jls-6.7-210-A.1"></a>In that case, the
                            canonical name of <span class="type">M</span> consists of the canonical name of
                            <span class="type">C</span>, followed by "<code class="literal">.</code>", followed by the simple name
                            of <span class="type">M</span>.
                     </p>
                  </li>
                  <li class="listitem">
                     <p class="norm"><a name="jls-6.7-210-B"></a>An array type has a
                            canonical name if and only if its component type has a canonical
                            name.
                     </p>
                     <p class="norm"><a name="jls-6.7-210-B.1"></a>In that case, the
                            canonical name of the array type consists of the canonical name of
                            the component type of the array type followed by
                            "<code class="literal">[]</code>".
                     </p>
                  </li>
               </ul>
            </div>
            <p class="norm"><a name="jls-6.7-220"></a>A local class does not have a
               canonical name.
            </p>
            <div class="example"><a name="d5e10075"></a><p class="title"><b>Example&nbsp;6.7-1.&nbsp;Fully Qualified Names</b></p>
               <div class="example-contents">
                  <div class="note">
                     <ul class="note" type="disc">
                        <li class="listitem">
                           <p class="note">The fully qualified name of the type <code class="literal">long</code> is
                                    "<code class="literal">long</code>".
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="note">The fully qualified name of the package
                                    <code class="literal">java.lang</code> is "<code class="literal">java.lang</code>" because it is
                                    subpackage <code class="literal">lang</code> of
                                    package <code class="literal">java</code>.
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="note">The fully qualified name of the class <code class="literal">Object</code>,
                                    which is defined in the package <code class="literal">java.lang</code>, is
                                    "<code class="literal">java.lang.Object</code>".
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="note">The fully qualified name of the
                                    interface <code class="literal">Enumeration</code>, which is defined in
                                    the package <code class="literal">java.util</code>, is
                                    "<code class="literal">java.util.Enumeration</code>".
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="note">The fully qualified name of the type "array of
                                    <code class="literal">double</code>" is "<code class="literal">double</code><code class="literal">[]</code>".
                           </p>
                        </li>
                        <li class="listitem">
                           <p class="note">The fully qualified name of the type "array of
                                    array of array of array of <code class="literal">String</code>" is
                                    "<code class="literal">java.lang.String[][][][]</code>".
                           </p>
                        </li>
                     </ul>
                  </div>
                  <p class="note">In the code:</p><pre class="programlisting">
package points;
class Point    { int x, y; }
class PointVec { Point[] vec; }
</pre><p class="note">the fully qualified name of the
                     type <code class="literal">Point</code> is "<code class="literal">points.Point</code>";
                     the fully qualified name of the type <code class="literal">PointVec</code> is
                     "<code class="literal">points.PointVec</code>"; and the fully qualified name of
                     the type of the field <code class="literal">vec</code> of
                     class <code class="literal">PointVec</code> is
                     "<code class="literal">points.Point[]</code>".
                  </p>
               </div>
            </div><br class="example-break"><div class="example"><a name="d5e10117"></a><p class="title"><b>Example&nbsp;6.7-2.&nbsp;Fully Qualified Names v. Canonical Name</b></p>
               <div class="example-contents">
                  <p class="note">The difference between a fully qualified name and a
                     canonical name can be seen in code such as:
                  </p><pre class="programlisting">
package p;
class O1 { class I {} }
class O2 extends O1 {}
</pre><p class="note">Both <code class="literal">p.O1.I</code>
                     and <code class="literal">p.O2.I</code> are fully qualified names that denote
                     the member class <code class="literal">I</code>, but
                     only <code class="literal">p.O1.I</code> is its canonical name.
                  </p>
               </div>
            </div><br class="example-break"></div>
      </div>
      <div class="navfooter">
         <hr>
         <table width="100%" summary="Navigation footer">
            <tr>
               <td width="40%" align="left"><a accesskey="p" href="jls-5.html">Prev</a>&nbsp;
               </td>
               <td width="20%" align="center">&nbsp;</td>
               <td width="40%" align="right">&nbsp;<a accesskey="n" href="jls-7.html">Next</a></td>
            </tr>
            <tr>
               <td width="40%" align="left" valign="top">Chapter&nbsp;5.&nbsp;Conversions and Contexts&nbsp;</td>
               <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
               <td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;7.&nbsp;Packages</td>
            </tr>
         </table>
      </div>
      <div xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:rx="http://www.renderx.com/XSL/Extensions" class="navfooter">
         <hr><a href="jls-0-front.html">
                Legal Notice
              </a></div>
   </body>
</html>